mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
Changed redirect logic on login and 2fa to use callbacks
This commit is contained in:
@@ -26,6 +26,7 @@ import { flagEnabled } from "../../platform/flags";
|
|||||||
})
|
})
|
||||||
export class LoginComponent extends BaseLoginComponent {
|
export class LoginComponent extends BaseLoginComponent {
|
||||||
showPasswordless = false;
|
showPasswordless = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
devicesApiService: DevicesApiServiceAbstraction,
|
devicesApiService: DevicesApiServiceAbstraction,
|
||||||
appIdService: AppIdService,
|
appIdService: AppIdService,
|
||||||
@@ -66,7 +67,35 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
super.onSuccessfulLogin = async () => {
|
super.onSuccessfulLogin = async () => {
|
||||||
await syncService.fullSync(true);
|
await syncService.fullSync(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
super.successRoute = "/tabs/vault";
|
super.successRoute = "/tabs/vault";
|
||||||
|
|
||||||
|
super.onSuccessfulLoginNavigate = async () => {
|
||||||
|
// The `redirectUrl` parameter determines the target route after a successful login.
|
||||||
|
// If provided in the URL's query parameters, the user will be redirected
|
||||||
|
// to the specified path once they are authenticated.
|
||||||
|
this.successRoute = this.route.snapshot.queryParams.redirectUrl
|
||||||
|
? decodeURIComponent(this.route.snapshot.queryParams.redirectUrl)
|
||||||
|
: this.successRoute;
|
||||||
|
|
||||||
|
this.router.navigateByUrl(this.successRoute);
|
||||||
|
};
|
||||||
|
|
||||||
|
super.onSuccessfulLoginTwoFactorNavigate = async () => {
|
||||||
|
// The `redirectUrl` parameter determines the target route after a successful login.
|
||||||
|
// If provided in the URL's query parameters, the user will be redirected
|
||||||
|
// to the specified path once they are authenticated.
|
||||||
|
const redirectUrl = this.route.snapshot.queryParams.redirectUrl
|
||||||
|
? decodeURIComponent(this.route.snapshot.queryParams.redirectUrl)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
this.router.navigate([this.twoFactorRoute], {
|
||||||
|
queryParams: {
|
||||||
|
redirectUrl: redirectUrl,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.showPasswordless = flagEnabled("showPasswordless");
|
this.showPasswordless = flagEnabled("showPasswordless");
|
||||||
|
|
||||||
if (this.showPasswordless) {
|
if (this.showPasswordless) {
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const BroadcasterSubscriptionId = "TwoFactorComponent";
|
|||||||
})
|
})
|
||||||
export class TwoFactorComponent extends BaseTwoFactorComponent {
|
export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||||
showNewWindowMessage = false;
|
showNewWindowMessage = false;
|
||||||
redirectUrl: string;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
authService: AuthService,
|
authService: AuthService,
|
||||||
@@ -75,16 +74,6 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
syncService.fullSync(true);
|
syncService.fullSync(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
super.onSuccessfulLoginNavigate = async () => {
|
|
||||||
// The `redirectUrl` parameter determines the target route after a successful login.
|
|
||||||
// If provided in the URL's query parameters, the user will be redirected
|
|
||||||
// to the specified path once they are authenticated.
|
|
||||||
if (this.route.snapshot.queryParams.redirectUrl) {
|
|
||||||
this.redirectUrl = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
|
|
||||||
this.router.navigateByUrl(this.redirectUrl);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
super.onSuccessfulLoginTde = async () => {
|
super.onSuccessfulLoginTde = async () => {
|
||||||
syncService.fullSync(true);
|
syncService.fullSync(true);
|
||||||
};
|
};
|
||||||
@@ -94,6 +83,18 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
super.successRoute = "/tabs/vault";
|
super.successRoute = "/tabs/vault";
|
||||||
|
|
||||||
|
super.onSuccessfulLoginNavigate = async () => {
|
||||||
|
// The `redirectUrl` parameter determines the target route after a successful login.
|
||||||
|
// If provided in the URL's query parameters, the user will be redirected
|
||||||
|
// to the specified path once they are authenticated.
|
||||||
|
this.successRoute = this.route.snapshot.queryParams.redirectUrl
|
||||||
|
? decodeURIComponent(this.route.snapshot.queryParams.redirectUrl)
|
||||||
|
: this.successRoute;
|
||||||
|
|
||||||
|
this.router.navigateByUrl(this.successRoute);
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME: Chromium 110 has broken WebAuthn support in extensions via an iframe
|
// FIXME: Chromium 110 has broken WebAuthn support in extensions via an iframe
|
||||||
this.webAuthnNewTab = true;
|
this.webAuthnNewTab = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
|
|||||||
showLoginWithDevice: boolean;
|
showLoginWithDevice: boolean;
|
||||||
validatedEmail = false;
|
validatedEmail = false;
|
||||||
paramEmailSet = false;
|
paramEmailSet = false;
|
||||||
redirectUrl: string;
|
|
||||||
|
|
||||||
formGroup = this.formBuilder.group({
|
formGroup = this.formBuilder.group({
|
||||||
email: ["", [Validators.required, Validators.email]],
|
email: ["", [Validators.required, Validators.email]],
|
||||||
@@ -119,14 +118,6 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
async submit(showToast = true) {
|
async submit(showToast = true) {
|
||||||
// The `redirectUrl` parameter determines the target route after a successful login.
|
|
||||||
// If provided in the URL's query parameters, the user will be redirected
|
|
||||||
// to the specified path once they are authenticated.
|
|
||||||
if (this.route.snapshot.queryParams.redirectUrl) {
|
|
||||||
this.redirectUrl = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
|
|
||||||
this.successRoute = this.redirectUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = this.formGroup.value;
|
const data = this.formGroup.value;
|
||||||
|
|
||||||
await this.setupCaptcha();
|
await this.setupCaptcha();
|
||||||
@@ -162,11 +153,7 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
|
|||||||
if (this.onSuccessfulLoginTwoFactorNavigate != null) {
|
if (this.onSuccessfulLoginTwoFactorNavigate != null) {
|
||||||
this.onSuccessfulLoginTwoFactorNavigate();
|
this.onSuccessfulLoginTwoFactorNavigate();
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate([this.twoFactorRoute], {
|
this.router.navigate([this.twoFactorRoute]);
|
||||||
queryParams: {
|
|
||||||
redirectUrl: this.redirectUrl,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if (response.forcePasswordReset != ForceResetPasswordReason.None) {
|
} else if (response.forcePasswordReset != ForceResetPasswordReason.None) {
|
||||||
if (this.onSuccessfulLoginForceResetNavigate != null) {
|
if (this.onSuccessfulLoginForceResetNavigate != null) {
|
||||||
@@ -181,7 +168,7 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
|
|||||||
if (this.onSuccessfulLoginNavigate != null) {
|
if (this.onSuccessfulLoginNavigate != null) {
|
||||||
this.onSuccessfulLoginNavigate();
|
this.onSuccessfulLoginNavigate();
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl(this.successRoute);
|
this.router.navigate([this.successRoute]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user