1
0
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:
gbubemismith
2023-09-07 22:21:01 -04:00
parent 003990b23f
commit 99399df8dc
9 changed files with 14 additions and 50 deletions

View File

@@ -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 });
}

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}
}