[Proposal] Add private key regen to onSuccessfulLogin
This commit is contained in:
parent
4769f86190
commit
6d2e7eef3a
|
@ -21,9 +21,11 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
|||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||
import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||
|
||||
import { flagEnabled } from "../../platform/flags";
|
||||
|
||||
|
@ -55,6 +57,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
|||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||
registerRouteService: RegisterRouteService,
|
||||
toastService: ToastService,
|
||||
userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||
) {
|
||||
super(
|
||||
devicesApiService,
|
||||
|
@ -78,8 +81,9 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
|||
registerRouteService,
|
||||
toastService,
|
||||
);
|
||||
this.onSuccessfulLogin = async () => {
|
||||
this.onSuccessfulLogin = async (userId: UserId) => {
|
||||
await syncService.fullSync(true);
|
||||
await userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||
};
|
||||
this.successRoute = "/tabs/vault";
|
||||
this.showPasswordless = flagEnabled("showPasswordless");
|
||||
|
|
|
@ -26,7 +26,12 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||
import {
|
||||
KeyService,
|
||||
BiometricsService,
|
||||
BiometricStateService,
|
||||
UserAsymmetricKeysRegenerationService,
|
||||
} from "@bitwarden/key-management";
|
||||
|
||||
const BroadcasterSubscriptionId = "LockComponent";
|
||||
|
||||
|
@ -71,6 +76,7 @@ export class LockComponent extends BaseLockComponent implements OnInit, OnDestro
|
|||
kdfConfigService: KdfConfigService,
|
||||
syncService: SyncService,
|
||||
toastService: ToastService,
|
||||
userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||
) {
|
||||
super(
|
||||
masterPasswordService,
|
||||
|
@ -100,6 +106,7 @@ export class LockComponent extends BaseLockComponent implements OnInit, OnDestro
|
|||
kdfConfigService,
|
||||
syncService,
|
||||
toastService,
|
||||
userAsymmetricKeysRegenerationService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,11 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
|
|||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||
import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||
|
||||
import { EnvironmentComponent } from "../environment.component";
|
||||
|
||||
|
@ -79,6 +81,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
|
|||
registerRouteService: RegisterRouteService,
|
||||
toastService: ToastService,
|
||||
private configService: ConfigService,
|
||||
userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||
) {
|
||||
super(
|
||||
devicesApiService,
|
||||
|
@ -102,8 +105,10 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
|
|||
registerRouteService,
|
||||
toastService,
|
||||
);
|
||||
this.onSuccessfulLogin = () => {
|
||||
return syncService.fullSync(true);
|
||||
this.onSuccessfulLogin = (userId: UserId) => {
|
||||
return syncService.fullSync(true).then(() => {
|
||||
userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||
import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||
|
||||
import { flagEnabled } from "../../../utils/flags";
|
||||
import { RouterService } from "../../core";
|
||||
|
@ -74,6 +76,8 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
|||
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||
registerRouteService: RegisterRouteService,
|
||||
toastService: ToastService,
|
||||
userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||
syncService: SyncService,
|
||||
) {
|
||||
super(
|
||||
devicesApiService,
|
||||
|
@ -97,6 +101,10 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
|
|||
registerRouteService,
|
||||
toastService,
|
||||
);
|
||||
this.onSuccessfulLogin = async (userId: UserId) => {
|
||||
await syncService.fullSync(true);
|
||||
await userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||
};
|
||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||
this.showPasswordless = flagEnabled("showPasswordless");
|
||||
}
|
||||
|
|
|
@ -326,8 +326,9 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
|
||||
await this.syncService.fullSync(false);
|
||||
|
||||
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
||||
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(
|
||||
this.activeUserId,
|
||||
);
|
||||
|
||||
if (this.onSuccessfulSubmit != null) {
|
||||
await this.onSuccessfulSubmit();
|
||||
|
|
|
@ -41,7 +41,7 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
|
|||
showPassword = false;
|
||||
formPromise: Promise<AuthResult>;
|
||||
|
||||
onSuccessfulLogin: () => Promise<any>;
|
||||
onSuccessfulLogin: (userId: UserId) => Promise<any>;
|
||||
onSuccessfulLoginNavigate: (userId: UserId) => Promise<any>;
|
||||
onSuccessfulLoginTwoFactorNavigate: () => Promise<any>;
|
||||
onSuccessfulLoginForceResetNavigate: () => Promise<any>;
|
||||
|
@ -208,7 +208,7 @@ export class LoginComponentV1 extends CaptchaProtectedComponent implements OnIni
|
|||
if (this.onSuccessfulLogin != null) {
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.onSuccessfulLogin();
|
||||
this.onSuccessfulLogin(response.userId);
|
||||
}
|
||||
|
||||
if (this.onSuccessfulLoginNavigate != null) {
|
||||
|
|
|
@ -534,8 +534,9 @@ export class LockV2Component implements OnInit, OnDestroy {
|
|||
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
|
||||
await this.syncService.fullSync(false);
|
||||
|
||||
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
||||
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(
|
||||
this.activeAccount.id,
|
||||
);
|
||||
|
||||
if (this.clientType === "browser") {
|
||||
const previousUrl = this.lockComponentService.getPreviousUrl();
|
||||
|
|
|
@ -42,6 +42,7 @@ import {
|
|||
LinkModule,
|
||||
ToastService,
|
||||
} from "@bitwarden/components";
|
||||
import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||
|
||||
import { AnonLayoutWrapperDataService } from "../anon-layout/anon-layout-wrapper-data.service";
|
||||
import { VaultIcon, WaveIcon } from "../icons";
|
||||
|
@ -142,6 +143,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||
private logService: LogService,
|
||||
private validationService: ValidationService,
|
||||
private configService: ConfigService,
|
||||
private userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||
) {
|
||||
this.clientType = this.platformUtilsService.getClientType();
|
||||
this.loginViaAuthRequestSupported = this.loginComponentService.isLoginViaAuthRequestSupported();
|
||||
|
@ -298,6 +300,9 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
await this.syncService.fullSync(true);
|
||||
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(
|
||||
authResult.userId,
|
||||
);
|
||||
|
||||
if (authResult.forcePasswordReset != ForceSetPasswordReason.None) {
|
||||
this.loginEmailService.clearValues();
|
||||
|
|
Loading…
Reference in New Issue