mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
PM-1391-Added previous-url to global-state (#5733)
* added previous-url to global-state * updated storage of previousUrl for SSO/MFA flows * revert file changes * added post login routing * Clear PreviousUrl from storage on new Login * Components do not call StateService anymore * removed needed query params * refactored components to use RouterService * fixed build error * fixed mfa component * updated logic for previous Url * removed unneeded base implementation * Added state call for Redirect Guard * Fixed test cases * Remove routing service calls * renamed global field, changed routing to guard * reverting constructor changes and git lint issue * fixing constructor ordering * fixing diffs to be clearer on actual cahnges. * addressing accepting emergency access case * refactor and add locked state logic * refactor name of guard to be more clear * Added comments and tests * comments + support lock page deep linking + code ownership * readability updates * Combined guards and specs updated routing * Update oss-routing.module.ts * fixed stroybook build
This commit is contained in:
@@ -4,6 +4,8 @@ import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
||||
import { filter } from "rxjs";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
|
||||
@Injectable()
|
||||
export class RouterService {
|
||||
@@ -14,6 +16,7 @@ export class RouterService {
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private titleService: Title,
|
||||
private stateService: StateService,
|
||||
i18nService: I18nService
|
||||
) {
|
||||
this.currentUrl = this.router.url;
|
||||
@@ -51,11 +54,33 @@ export class RouterService {
|
||||
});
|
||||
}
|
||||
|
||||
getPreviousUrl() {
|
||||
getPreviousUrl(): string | undefined {
|
||||
return this.previousUrl;
|
||||
}
|
||||
|
||||
setPreviousUrl(url: string) {
|
||||
setPreviousUrl(url: string): void {
|
||||
this.previousUrl = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save URL to Global State. This service is used during the login process
|
||||
* @param url URL being saved to the Global State
|
||||
*/
|
||||
async persistLoginRedirectUrl(url: string): Promise<void> {
|
||||
await this.stateService.setDeepLinkRedirectUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and clear persisted LoginRedirectUrl if present in state
|
||||
*/
|
||||
async getAndClearLoginRedirectUrl(): Promise<string> | undefined {
|
||||
const persistedPreLoginUrl = await this.stateService.getDeepLinkRedirectUrl();
|
||||
|
||||
if (!Utils.isNullOrEmpty(persistedPreLoginUrl)) {
|
||||
await this.persistLoginRedirectUrl(null);
|
||||
return persistedPreLoginUrl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user