mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
refactored router service to not store on the disk
This commit is contained in:
@@ -22,12 +22,12 @@ export const fido2AuthGuard: CanActivateFn = async (
|
||||
const authStatus = await authService.getAuthStatus();
|
||||
|
||||
if (authStatus === AuthenticationStatus.LoggedOut) {
|
||||
await routerService.setPreviousUrl(state.url);
|
||||
routerService.setPreviousUrl(state.url);
|
||||
return router.createUrlTree(["/home"], { queryParams: route.queryParams });
|
||||
}
|
||||
|
||||
if (authStatus === AuthenticationStatus.Locked) {
|
||||
await routerService.setPreviousUrl(state.url);
|
||||
routerService.setPreviousUrl(state.url);
|
||||
return router.createUrlTree(["/lock"], { queryParams: route.queryParams });
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ export class LockComponent extends BaseLockComponent {
|
||||
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
||||
|
||||
super.onSuccessfulSubmit = async () => {
|
||||
const previousUrl = await this.routerService.getPreviousUrl();
|
||||
const previousUrl = this.routerService.getPreviousUrl();
|
||||
if (previousUrl) {
|
||||
this.router.navigateByUrl(previousUrl);
|
||||
} else {
|
||||
|
||||
@@ -73,7 +73,7 @@ export class LoginComponent extends BaseLoginComponent {
|
||||
super.successRoute = "/tabs/vault";
|
||||
|
||||
super.onSuccessfulLoginNavigate = async () => {
|
||||
const previousUrl = await this.routerService.getPreviousUrl();
|
||||
const previousUrl = this.routerService.getPreviousUrl();
|
||||
|
||||
if (previousUrl) {
|
||||
this.router.navigateByUrl(previousUrl);
|
||||
|
||||
@@ -87,7 +87,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
super.successRoute = "/tabs/vault";
|
||||
|
||||
super.onSuccessfulLoginNavigate = async () => {
|
||||
const previousUrl = await this.routerService.getPreviousUrl();
|
||||
const previousUrl = this.routerService.getPreviousUrl();
|
||||
|
||||
if (previousUrl) {
|
||||
this.router.navigateByUrl(previousUrl);
|
||||
|
||||
@@ -8,7 +8,9 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
||||
providedIn: "root",
|
||||
})
|
||||
export class BrowserRouterService {
|
||||
constructor(router: Router, private stateService: StateService) {
|
||||
private previousUrl: string = undefined;
|
||||
|
||||
constructor(private router: Router, private stateService: StateService) {
|
||||
router.events
|
||||
.pipe(filter((e) => e instanceof NavigationEnd))
|
||||
.subscribe((event: NavigationEnd) => {
|
||||
@@ -27,16 +29,11 @@ export class BrowserRouterService {
|
||||
});
|
||||
}
|
||||
|
||||
async getPreviousUrl() {
|
||||
return this.stateService.getPreviousUrl();
|
||||
getPreviousUrl() {
|
||||
return this.previousUrl;
|
||||
}
|
||||
|
||||
// Check validity of previous url
|
||||
async hasPreviousUrl() {
|
||||
return (await this.getPreviousUrl()) != "/";
|
||||
}
|
||||
|
||||
async setPreviousUrl(url: string) {
|
||||
await this.stateService.setPreviousUrl(url);
|
||||
setPreviousUrl(url: string) {
|
||||
this.previousUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user