From 3857ee2370e59208b2ce1417c917fec394207076 Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Tue, 10 Aug 2021 07:10:54 -0500 Subject: [PATCH] [Reset Password v1] Update Temp Password (#1111) * [Reset Password v1] Update Temp Password * Updated event string * updated jslib Co-authored-by: addison --- jslib | 2 +- .../update-temp-password.component.html | 81 +++++++++++++++++++ .../update-temp-password.component.ts | 27 +++++++ src/app/oss-routing.module.ts | 7 ++ src/app/oss.module.ts | 2 + src/app/services/event.service.ts | 3 + src/app/vault/vault.component.ts | 4 + src/locales/en/messages.json | 9 +++ 8 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 src/app/accounts/update-temp-password.component.html create mode 100644 src/app/accounts/update-temp-password.component.ts diff --git a/jslib b/jslib index 027747246c9..c2e434e3334 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 027747246c9c15b976ad1aa0a1df563afaa9de21 +Subproject commit c2e434e33346a1bc791b50d6dddeb87f1349b0f3 diff --git a/src/app/accounts/update-temp-password.component.html b/src/app/accounts/update-temp-password.component.html new file mode 100644 index 00000000000..59685dee932 --- /dev/null +++ b/src/app/accounts/update-temp-password.component.html @@ -0,0 +1,81 @@ +
+
+
+

{{'updateMasterPassword' | i18n}}

+
+
+ {{'updateMasterPasswordWarning' | i18n}} + +
+ + {{'masterPasswordPolicyInEffect' | i18n}} +
    +
  • + {{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}} +
  • +
  • + {{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}} +
  • +
  • + {{'policyInEffectUppercase' | i18n}}
  • +
  • + {{'policyInEffectLowercase' | i18n}}
  • +
  • + {{'policyInEffectNumbers' | i18n}}
  • +
  • + {{'policyInEffectSpecial' | i18n : '!@#$%^&*'}}
  • +
+
+ +
+
+ + + +
+
+ + +
+
+
+
+ +
+ + +
+
+
+ + + {{'masterPassHintDesc' | i18n}} +
+
+
+ + +
+
+
+
+
+
diff --git a/src/app/accounts/update-temp-password.component.ts b/src/app/accounts/update-temp-password.component.ts new file mode 100644 index 00000000000..2ae67464648 --- /dev/null +++ b/src/app/accounts/update-temp-password.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; + +import { ApiService } from 'jslib-common/abstractions/api.service'; +import { CryptoService } from 'jslib-common/abstractions/crypto.service'; +import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { MessagingService } from 'jslib-common/abstractions/messaging.service'; +import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service'; +import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; +import { PolicyService } from 'jslib-common/abstractions/policy.service'; +import { UserService } from 'jslib-common/abstractions/user.service'; + +import { UpdateTempPasswordComponent as BaseUpdateTempPasswordComponent } from 'jslib-angular/components/update-temp-password.component'; + +@Component({ + selector: 'app-update-temp-password', + templateUrl: 'update-temp-password.component.html', +}) + +export class UpdateTempPasswordComponent extends BaseUpdateTempPasswordComponent { + constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService, + passwordGenerationService: PasswordGenerationService, policyService: PolicyService, + cryptoService: CryptoService, userService: UserService, + messagingService: MessagingService, apiService: ApiService) { + super(i18nService, platformUtilsService, passwordGenerationService, policyService, cryptoService, + userService, messagingService, apiService); + } +} diff --git a/src/app/oss-routing.module.ts b/src/app/oss-routing.module.ts index eb712de2cd5..85e47a41e18 100644 --- a/src/app/oss-routing.module.ts +++ b/src/app/oss-routing.module.ts @@ -19,6 +19,7 @@ import { RegisterComponent } from './accounts/register.component'; import { SetPasswordComponent } from './accounts/set-password.component'; import { SsoComponent } from './accounts/sso.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; +import { UpdateTempPasswordComponent } from './accounts/update-temp-password.component'; import { VerifyEmailTokenComponent } from './accounts/verify-email-token.component'; import { VerifyRecoverDeleteComponent } from './accounts/verify-recover-delete.component'; @@ -163,6 +164,12 @@ const routes: Routes = [ component: AccessComponent, data: { title: 'Bitwarden Send' }, }, + { + path: 'update-temp-password', + component: UpdateTempPasswordComponent, + canActivate: [AuthGuardService], + data: { titleId: 'updateTempPassword' }, + }, ], }, { diff --git a/src/app/oss.module.ts b/src/app/oss.module.ts index 26c20258954..2c926bdd559 100644 --- a/src/app/oss.module.ts +++ b/src/app/oss.module.ts @@ -35,6 +35,7 @@ import { SetPasswordComponent } from './accounts/set-password.component'; import { SsoComponent } from './accounts/sso.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorComponent } from './accounts/two-factor.component'; +import { UpdateTempPasswordComponent } from './accounts/update-temp-password.component'; import { VerifyEmailTokenComponent } from './accounts/verify-email-token.component'; import { VerifyRecoverDeleteComponent } from './accounts/verify-recover-delete.component'; @@ -426,6 +427,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); UnsecuredWebsitesReportComponent, UpdateKeyComponent, UpdateLicenseComponent, + UpdateTempPasswordComponent, UserBillingComponent, UserLayoutComponent, UserSubscriptionComponent, diff --git a/src/app/services/event.service.ts b/src/app/services/event.service.ts index 7a6bef3fae8..75e1de8309c 100644 --- a/src/app/services/event.service.ts +++ b/src/app/services/event.service.ts @@ -71,6 +71,9 @@ export class EventService { case EventType.User_ClientExportedVault: msg = humanReadableMsg = this.i18nService.t('exportedVault'); break; + case EventType.User_UpdatedTempPassword: + msg = humanReadableMsg = this.i18nService.t('updatedMasterPassword'); + break; // Cipher case EventType.Cipher_Created: msg = this.i18nService.t('createdItemId', this.formatCipherId(ev, options)); diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index c60d293abfd..157307d4375 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -88,6 +88,10 @@ export class VaultComponent implements OnInit, OnDestroy { const queryParamsSub = this.route.queryParams.subscribe(async params => { await this.syncService.fullSync(false); + if (await this.userService.getForcePasswordReset()) { + this.router.navigate(['update-temp-password']); + } + this.showUpdateKey = !(await this.cryptoService.hasEncKey()); const canAccessPremium = await this.userService.canAccessPremium(); this.showPremiumCallout = !this.showVerifyEmail && !canAccessPremium && diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 925bd977963..3025961e0f0 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -4180,5 +4180,14 @@ }, "add": { "message": "Add" + }, + "updatedMasterPassword": { + "message": "Updated Master Password" + }, + "updateMasterPassword": { + "message": "Update Master Password" + }, + "updateMasterPasswordWarning": { + "message": "Your Master Password was recently changed by an administrator in your organization. In order to access the vault, you must update your Master Password now. Proceeding will log you out of your current session, requiring you to log back in. Active sessions on other devices may continue to remain active for up to one hour." } }