1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 03:33:54 +00:00

Changed redirect logic on login and 2fa to use callbacks

This commit is contained in:
gbubemismith
2023-08-24 17:08:22 -04:00
parent b0dadca574
commit 1020c5c26e
3 changed files with 43 additions and 26 deletions

View File

@@ -26,6 +26,7 @@ import { flagEnabled } from "../../platform/flags";
})
export class LoginComponent extends BaseLoginComponent {
showPasswordless = false;
constructor(
devicesApiService: DevicesApiServiceAbstraction,
appIdService: AppIdService,
@@ -66,7 +67,35 @@ export class LoginComponent extends BaseLoginComponent {
super.onSuccessfulLogin = async () => {
await syncService.fullSync(true);
};
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");
if (this.showPasswordless) {

View File

@@ -32,7 +32,6 @@ const BroadcasterSubscriptionId = "TwoFactorComponent";
})
export class TwoFactorComponent extends BaseTwoFactorComponent {
showNewWindowMessage = false;
redirectUrl: string;
constructor(
authService: AuthService,
@@ -75,16 +74,6 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
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 () => {
syncService.fullSync(true);
};
@@ -94,6 +83,18 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
};
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
this.webAuthnNewTab = true;
}