mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Updated components to use browserRouterService for routing to previous page
This commit is contained in:
@@ -81,16 +81,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.loginService.setEmail(this.formGroup.value.email);
|
this.loginService.setEmail(this.formGroup.value.email);
|
||||||
this.loginService.setRememberEmail(this.formGroup.value.rememberEmail);
|
this.loginService.setRememberEmail(this.formGroup.value.rememberEmail);
|
||||||
|
this.router.navigate(["login"], { queryParams: { email: this.formGroup.value.email } });
|
||||||
const queryParams: { email: string; redirectUrl?: string } = {
|
|
||||||
email: this.formGroup.value.email,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.route.snapshot.queryParams.redirectUrl) {
|
|
||||||
queryParams.redirectUrl = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.router.navigate(["login"], { queryParams });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get selfHostedDomain() {
|
get selfHostedDomain() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, NgZone } from "@angular/core";
|
import { Component, NgZone } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component";
|
import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
@@ -22,6 +22,7 @@ import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/pass
|
|||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
|
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
|
||||||
|
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-lock",
|
selector: "app-lock",
|
||||||
@@ -50,10 +51,10 @@ export class LockComponent extends BaseLockComponent {
|
|||||||
policyService: InternalPolicyService,
|
policyService: InternalPolicyService,
|
||||||
passwordStrengthService: PasswordStrengthServiceAbstraction,
|
passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
route: ActivatedRoute,
|
|
||||||
dialogService: DialogService,
|
dialogService: DialogService,
|
||||||
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||||
userVerificationService: UserVerificationService
|
userVerificationService: UserVerificationService,
|
||||||
|
private routerService: BrowserRouterService
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
router,
|
router,
|
||||||
@@ -71,13 +72,21 @@ export class LockComponent extends BaseLockComponent {
|
|||||||
policyApiService,
|
policyApiService,
|
||||||
policyService,
|
policyService,
|
||||||
passwordStrengthService,
|
passwordStrengthService,
|
||||||
route,
|
|
||||||
dialogService,
|
dialogService,
|
||||||
deviceTrustCryptoService,
|
deviceTrustCryptoService,
|
||||||
userVerificationService
|
userVerificationService
|
||||||
);
|
);
|
||||||
this.successRoute = "/tabs/current";
|
this.successRoute = "/tabs/current";
|
||||||
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
||||||
|
|
||||||
|
super.onSuccessfulSubmit = async () => {
|
||||||
|
const previousUrl = await this.routerService.getPreviousUrl();
|
||||||
|
if (previousUrl) {
|
||||||
|
this.router.navigateByUrl(previousUrl);
|
||||||
|
} else {
|
||||||
|
this.router.navigate([this.successRoute]);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
|
|
||||||
import { flagEnabled } from "../../platform/flags";
|
import { flagEnabled } from "../../platform/flags";
|
||||||
|
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
@@ -44,7 +45,8 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
formBuilder: FormBuilder,
|
formBuilder: FormBuilder,
|
||||||
formValidationErrorService: FormValidationErrorsService,
|
formValidationErrorService: FormValidationErrorsService,
|
||||||
route: ActivatedRoute,
|
route: ActivatedRoute,
|
||||||
loginService: LoginService
|
loginService: LoginService,
|
||||||
|
private routerService: BrowserRouterService
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
@@ -71,29 +73,14 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
super.successRoute = "/tabs/vault";
|
super.successRoute = "/tabs/vault";
|
||||||
|
|
||||||
super.onSuccessfulLoginNavigate = async () => {
|
super.onSuccessfulLoginNavigate = async () => {
|
||||||
// The `redirectUrl` parameter determines the target route after a successful login.
|
const previousUrl = await this.routerService.getPreviousUrl();
|
||||||
// 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);
|
if (previousUrl) {
|
||||||
};
|
this.router.navigateByUrl(previousUrl);
|
||||||
|
} else {
|
||||||
super.onSuccessfulLoginTwoFactorNavigate = async () => {
|
this.loginService.clearValues();
|
||||||
// The `redirectUrl` parameter determines the target route after a successful login.
|
this.router.navigate([this.successRoute]);
|
||||||
// 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");
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
|||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
|
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
|
||||||
import { PopupUtilsService } from "../../popup/services/popup-utils.service";
|
import { PopupUtilsService } from "../../popup/services/popup-utils.service";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "TwoFactorComponent";
|
const BroadcasterSubscriptionId = "TwoFactorComponent";
|
||||||
@@ -52,6 +53,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
loginService: LoginService,
|
loginService: LoginService,
|
||||||
configService: ConfigServiceAbstraction,
|
configService: ConfigServiceAbstraction,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
|
private routerService: BrowserRouterService,
|
||||||
@Inject(WINDOW) protected win: Window
|
@Inject(WINDOW) protected win: Window
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
@@ -85,14 +87,13 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
super.successRoute = "/tabs/vault";
|
super.successRoute = "/tabs/vault";
|
||||||
|
|
||||||
super.onSuccessfulLoginNavigate = async () => {
|
super.onSuccessfulLoginNavigate = async () => {
|
||||||
// The `redirectUrl` parameter determines the target route after a successful login.
|
const previousUrl = await this.routerService.getPreviousUrl();
|
||||||
// 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);
|
if (previousUrl) {
|
||||||
|
this.router.navigateByUrl(previousUrl);
|
||||||
|
} else {
|
||||||
|
this.router.navigate([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
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { UserRequestedFallbackAbortReason } from "@bitwarden/common/vault/abstractions/fido2/fido2-client.service.abstraction";
|
import { UserRequestedFallbackAbortReason } from "@bitwarden/common/vault/abstractions/fido2/fido2-client.service.abstraction";
|
||||||
import {
|
import {
|
||||||
@@ -348,8 +347,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const authStatus = await this.authService.getAuthStatus();
|
this.popout = await this.generatePopOut();
|
||||||
this.popout = await this.generatePopOut(authStatus);
|
|
||||||
|
|
||||||
if (this.popout.type === "window") {
|
if (this.popout.type === "window") {
|
||||||
const popoutWindow = this.popout;
|
const popoutWindow = this.popout;
|
||||||
@@ -378,8 +376,7 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|||||||
await connectPromise;
|
await connectPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async generatePopOut(authStatus: AuthenticationStatus) {
|
private async generatePopOut() {
|
||||||
if (authStatus === AuthenticationStatus.Unlocked) {
|
|
||||||
const queryParams = new URLSearchParams({ sessionId: this.sessionId });
|
const queryParams = new URLSearchParams({ sessionId: this.sessionId });
|
||||||
return this.popupUtilsService.popOut(
|
return this.popupUtilsService.popOut(
|
||||||
null,
|
null,
|
||||||
@@ -387,28 +384,4 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
|||||||
{ center: true }
|
{ center: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path: string;
|
|
||||||
|
|
||||||
switch (authStatus) {
|
|
||||||
case AuthenticationStatus.LoggedOut:
|
|
||||||
path = "home";
|
|
||||||
break;
|
|
||||||
case AuthenticationStatus.Locked:
|
|
||||||
path = "lock";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unexpected auth status: ${authStatus}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const redirectUrlParams = new URLSearchParams({ sessionId: this.sessionId });
|
|
||||||
const redirectUrl = `/fido2?${redirectUrlParams.toString()}`;
|
|
||||||
|
|
||||||
const queryParams = new URLSearchParams({ redirectUrl });
|
|
||||||
return this.popupUtilsService.popOut(
|
|
||||||
null,
|
|
||||||
`popup/index.html?uilocation=popout#/${path}?${queryParams.toString()}`,
|
|
||||||
{ center: true }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Directive, NgZone, OnDestroy, OnInit } from "@angular/core";
|
import { Directive, NgZone, OnDestroy, OnInit } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { firstValueFrom, Subject } from "rxjs";
|
import { firstValueFrom, Subject } from "rxjs";
|
||||||
import { concatMap, take, takeUntil } from "rxjs/operators";
|
import { concatMap, take, takeUntil } from "rxjs/operators";
|
||||||
|
|
||||||
@@ -43,7 +43,6 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||||||
supportsBiometric: boolean;
|
supportsBiometric: boolean;
|
||||||
biometricLock: boolean;
|
biometricLock: boolean;
|
||||||
biometricText: string;
|
biometricText: string;
|
||||||
redirectUrl: string;
|
|
||||||
|
|
||||||
protected successRoute = "vault";
|
protected successRoute = "vault";
|
||||||
protected forcePasswordResetRoute = "update-temp-password";
|
protected forcePasswordResetRoute = "update-temp-password";
|
||||||
@@ -72,7 +71,6 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||||||
protected policyApiService: PolicyApiServiceAbstraction,
|
protected policyApiService: PolicyApiServiceAbstraction,
|
||||||
protected policyService: InternalPolicyService,
|
protected policyService: InternalPolicyService,
|
||||||
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||||
protected route: ActivatedRoute,
|
|
||||||
protected dialogService: DialogService,
|
protected dialogService: DialogService,
|
||||||
protected deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
protected deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||||
protected userVerificationService: UserVerificationService
|
protected userVerificationService: UserVerificationService
|
||||||
@@ -315,13 +313,6 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||||||
await this.stateService.setEverBeenUnlocked(true);
|
await this.stateService.setEverBeenUnlocked(true);
|
||||||
this.messagingService.send("unlocked");
|
this.messagingService.send("unlocked");
|
||||||
|
|
||||||
// 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.successRoute = decodeURIComponent(this.route.snapshot.queryParams.redirectUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evaluatePasswordAfterUnlock) {
|
if (evaluatePasswordAfterUnlock) {
|
||||||
try {
|
try {
|
||||||
// If we do not have any saved policies, attempt to load them from the service
|
// If we do not have any saved policies, attempt to load them from the service
|
||||||
@@ -347,7 +338,7 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||||||
if (this.onSuccessfulSubmit != null) {
|
if (this.onSuccessfulSubmit != null) {
|
||||||
await this.onSuccessfulSubmit();
|
await this.onSuccessfulSubmit();
|
||||||
} else if (this.router != null) {
|
} else if (this.router != null) {
|
||||||
this.router.navigateByUrl(this.successRoute);
|
this.router.navigate([this.successRoute]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
|
|||||||
let cipherOptions: CipherView[];
|
let cipherOptions: CipherView[];
|
||||||
|
|
||||||
//TODO: uncomment this when working on the login flow ticket
|
//TODO: uncomment this when working on the login flow ticket
|
||||||
await userInterfaceSession.ensureUnlockedVault();
|
// await userInterfaceSession.ensureUnlockedVault();
|
||||||
|
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
if (params.allowCredentialDescriptorList?.length > 0) {
|
if (params.allowCredentialDescriptorList?.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user