From 752e26db6d973f5185d8c96aaf62abb77aa9ca6a Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Fri, 28 Aug 2020 09:54:45 -0500 Subject: [PATCH] [SSO] Adjust set password flow (#64) * Removed set-password // Adjusted sso UI // Added string * Removed test logic * Update jslib (6ab444a -> 700e945) * Passing null for expectes sync service * Removing unnecessary async * Deleted set-password files. RIP * Removed non-existent import (fixes build) --- jslib | 2 +- src/app/accounts/set-password.component.html | 96 -------------------- src/app/accounts/set-password.component.ts | 61 ------------- src/app/accounts/sso.component.html | 18 +++- src/app/accounts/sso.component.ts | 27 +++++- src/app/app-routing.module.ts | 2 - src/app/app.module.ts | 2 - src/locales/en/messages.json | 6 ++ 8 files changed, 50 insertions(+), 164 deletions(-) delete mode 100644 src/app/accounts/set-password.component.html delete mode 100644 src/app/accounts/set-password.component.ts diff --git a/jslib b/jslib index 6ab444a9..700e9450 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 6ab444a9868c32ac53761f9d233d816744da9a1d +Subproject commit 700e945008edb38543d619e9dd4543908c057f5c diff --git a/src/app/accounts/set-password.component.html b/src/app/accounts/set-password.component.html deleted file mode 100644 index 35835493..00000000 --- a/src/app/accounts/set-password.component.html +++ /dev/null @@ -1,96 +0,0 @@ -
-
-
-
-
-
{{'setMasterPassword' | i18n}}
-
- {{'ssoCompleteRegistration' | i18n}} -
- - {{'masterPasswordPolicyInEffect' | i18n}} -
    -
  • - {{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}} -
  • -
  • - {{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}} -
  • -
  • - {{'policyInEffectUppercase' | i18n}}
  • -
  • - {{'policyInEffectLowercase' | i18n}}
  • -
  • - {{'policyInEffectNumbers' | i18n}}
  • -
  • - {{'policyInEffectSpecial' | i18n : '!@#$%^&*'}}
  • -
-
- -
-
- -
-
-
-
-
-
- - -
-
- {{'masterPassDesc' | i18n}} -
-
- -
- - -
-
-
- - - {{'masterPassHintDesc' | i18n}} -
-
-
- - -
-
-
-
-
-
-
diff --git a/src/app/accounts/set-password.component.ts b/src/app/accounts/set-password.component.ts deleted file mode 100644 index 7d8c49a4..00000000 --- a/src/app/accounts/set-password.component.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Component } from '@angular/core'; - -import { Router } from '@angular/router'; - -import { ApiService } from 'jslib/abstractions/api.service'; -import { CryptoService } from 'jslib/abstractions/crypto.service'; -import { I18nService } from 'jslib/abstractions/i18n.service'; -import { MessagingService } from 'jslib/abstractions/messaging.service'; -import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; -import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; -import { PolicyService } from 'jslib/abstractions/policy.service'; -import { UserService } from 'jslib/abstractions/user.service'; - -import { - SetPasswordComponent as BaseSetPasswordComponent, -} from 'jslib/angular/components/set-password.component'; - -@Component({ - selector: 'app-set-password', - templateUrl: 'set-password.component.html', -}) -export class SetPasswordComponent extends BaseSetPasswordComponent { - constructor(apiService: ApiService, i18nService: I18nService, - cryptoService: CryptoService, messagingService: MessagingService, - userService: UserService, passwordGenerationService: PasswordGenerationService, - platformUtilsService: PlatformUtilsService, policyService: PolicyService, router: Router) { - super(i18nService, cryptoService, messagingService, userService, passwordGenerationService, - platformUtilsService, policyService, router, apiService); - super.successRoute = '/tabs/dashboard'; - } - - get masterPasswordScoreWidth() { - return this.masterPasswordScore == null ? 0 : (this.masterPasswordScore + 1) * 20; - } - - get masterPasswordScoreColor() { - switch (this.masterPasswordScore) { - case 4: - return 'success'; - case 3: - return 'primary'; - case 2: - return 'warning'; - default: - return 'danger'; - } - } - - get masterPasswordScoreText() { - switch (this.masterPasswordScore) { - case 4: - return this.i18nService.t('strong'); - case 3: - return this.i18nService.t('good'); - case 2: - return this.i18nService.t('weak'); - default: - return this.masterPasswordScore != null ? this.i18nService.t('weak') : null; - } - } -} diff --git a/src/app/accounts/sso.component.html b/src/app/accounts/sso.component.html index 1685dff0..837c8d85 100644 --- a/src/app/accounts/sso.component.html +++ b/src/app/accounts/sso.component.html @@ -2,12 +2,28 @@
-
+
{{'loading' | i18n}}
+
+
{{'setMasterPassword' | i18n}}
+
+

{{'setMasterPasswordRedirect' | i18n}}

+
+
+ + +
+
+
diff --git a/src/app/accounts/sso.component.ts b/src/app/accounts/sso.component.ts index 1084aed4..8555927d 100644 --- a/src/app/accounts/sso.component.ts +++ b/src/app/accounts/sso.component.ts @@ -8,7 +8,9 @@ import { import { ApiService } from 'jslib/abstractions/api.service'; import { AuthService } from 'jslib/abstractions/auth.service'; import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service'; +import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { StateService } from 'jslib/abstractions/state.service'; @@ -21,16 +23,39 @@ import { SsoComponent as BaseSsoComponent } from 'jslib/angular/components/sso.c templateUrl: 'sso.component.html', }) export class SsoComponent extends BaseSsoComponent { + showMasterPassRedirect: boolean = false; + constructor(authService: AuthService, router: Router, i18nService: I18nService, route: ActivatedRoute, storageService: StorageService, stateService: StateService, platformUtilsService: PlatformUtilsService, apiService: ApiService, cryptoFunctionService: CryptoFunctionService, - passwordGenerationService: PasswordGenerationService) { + passwordGenerationService: PasswordGenerationService, private messagingService: MessagingService, + private environmentService: EnvironmentService) { super(authService, router, i18nService, route, storageService, stateService, platformUtilsService, apiService, cryptoFunctionService, passwordGenerationService); this.successRoute = '/tabs/dashboard'; this.redirectUri = 'bwdc://sso-callback'; this.clientId = 'connector'; + this.onSuccessfulLoginChangePasswordNavigate = this.redirectSetMasterPass; + } + + async redirectSetMasterPass() { + this.showMasterPassRedirect = true; + } + + launchWebVault() { + const webUrl = this.environmentService.webVaultUrl == null ? 'https://vault.bitwarden.com' : + this.environmentService.webVaultUrl; + + this.platformUtilsService.launchUri(webUrl); + } + + async logOut() { + const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('logOutConfirmation'), + this.i18nService.t('logOut'), this.i18nService.t('logOut'), this.i18nService.t('cancel')); + if (confirmed) { + this.messagingService.send('logout'); + } } } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index b8b6ae52..82fda652 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,7 +8,6 @@ import { AuthGuardService } from './services/auth-guard.service'; import { LaunchGuardService } from './services/launch-guard.service'; import { LoginComponent } from './accounts/login.component'; -import { SetPasswordComponent } from './accounts/set-password.component'; import { SsoComponent } from './accounts/sso.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; import { DashboardComponent } from './tabs/dashboard.component'; @@ -25,7 +24,6 @@ const routes: Routes = [ }, { path: '2fa', component: TwoFactorComponent }, { path: 'sso', component: SsoComponent }, - { path: 'set-password', component: SetPasswordComponent }, { path: 'tabs', component: TabsComponent, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1f2f2ece..30fccc20 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -26,7 +26,6 @@ import { TwoFactorOptionsComponent } from './accounts/two-factor-options.compone import { TwoFactorComponent } from './accounts/two-factor.component'; import { DashboardComponent } from './tabs/dashboard.component'; import { MoreComponent } from './tabs/more.component'; -import { SetPasswordComponent } from './accounts/set-password.component'; import { SettingsComponent } from './tabs/settings.component'; import { TabsComponent } from './tabs/tabs.component'; @@ -73,7 +72,6 @@ import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; ModalComponent, MoreComponent, SearchCiphersPipe, - SetPasswordComponent, SettingsComponent, SsoComponent, StopClickDirective, diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 70e48c17..c1500f5e 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -716,5 +716,11 @@ }, "loading": { "message": "Loading" + }, + "setMasterPasswordRedirect": { + "message": "In order to log in with SSO from the Directory Connector, you must first log in through the web vault to set your master password." + }, + "launchWebVault": { + "message": "Launch Web Vault" } }