mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +01:00
route to previous url after unlock
This commit is contained in:
parent
7ebd18b00d
commit
5db9e9531f
@ -13,6 +13,8 @@ import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { RouterService } from '../services/router.service';
|
||||
|
||||
import { LockComponent as BaseLockComponent } from 'jslib/angular/components/lock.component';
|
||||
|
||||
@Component({
|
||||
@ -23,7 +25,8 @@ export class LockComponent extends BaseLockComponent implements OnInit {
|
||||
constructor(router: Router, analytics: Angulartics2,
|
||||
toasterService: ToasterService, i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService, messagingService: MessagingService,
|
||||
userService: UserService, cryptoService: CryptoService) {
|
||||
userService: UserService, cryptoService: CryptoService,
|
||||
private routerService: RouterService) {
|
||||
super(router, analytics, toasterService, i18nService, platformUtilsService,
|
||||
messagingService, userService, cryptoService);
|
||||
}
|
||||
@ -36,5 +39,10 @@ export class LockComponent extends BaseLockComponent implements OnInit {
|
||||
} else if (key != null) {
|
||||
this.router.navigate(['vault']);
|
||||
}
|
||||
|
||||
const previousUrl = this.routerService.getPreviousUrl();
|
||||
if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) {
|
||||
this.successRoute = previousUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ import { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { ConstantsService } from 'jslib/services/constants.service';
|
||||
|
||||
import { RouterService } from './services/router.service';
|
||||
|
||||
const BroadcasterSubscriptionId = 'AppComponent';
|
||||
// Hack due to Angular 5.2 bug
|
||||
const swal: SweetAlert = _swal as any;
|
||||
@ -67,7 +69,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
private toasterService: ToasterService, private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService, private ngZone: NgZone,
|
||||
private lockService: LockService, private storageService: StorageService,
|
||||
private cryptoService: CryptoService, private collectionService: CollectionService) { }
|
||||
private cryptoService: CryptoService, private collectionService: CollectionService,
|
||||
private routerService: RouterService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.ngZone.runOutsideAngular(() => {
|
||||
|
@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { ServicesModule } from './services.module';
|
||||
import { ServicesModule } from './services/services.module';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { ModalComponent } from './modal.component';
|
||||
|
25
src/app/services/router.service.ts
Normal file
25
src/app/services/router.service.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
NavigationEnd,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class RouterService {
|
||||
private previousUrl: string = undefined;
|
||||
private currentUrl: string = undefined;
|
||||
|
||||
constructor(private router: Router) {
|
||||
this.currentUrl = this.router.url;
|
||||
router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.previousUrl = this.currentUrl;
|
||||
this.currentUrl = event.url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getPreviousUrl() {
|
||||
return this.previousUrl;
|
||||
}
|
||||
}
|
@ -5,13 +5,14 @@ import {
|
||||
|
||||
import { ToasterModule } from 'angular2-toaster';
|
||||
|
||||
import { BroadcasterMessagingService } from '../services/broadcasterMessaging.service';
|
||||
import { HtmlStorageService } from '../services/htmlStorage.service';
|
||||
import { I18nService } from '../services/i18n.service';
|
||||
import { MemoryStorageService } from '../services/memoryStorage.service';
|
||||
import { WebPlatformUtilsService } from '../services/webPlatformUtils.service';
|
||||
import { BroadcasterMessagingService } from '../../services/broadcasterMessaging.service';
|
||||
import { HtmlStorageService } from '../../services/htmlStorage.service';
|
||||
import { I18nService } from '../../services/i18n.service';
|
||||
import { MemoryStorageService } from '../../services/memoryStorage.service';
|
||||
import { WebPlatformUtilsService } from '../../services/webPlatformUtils.service';
|
||||
|
||||
import { UnauthGuardService } from './services/unauth-guard.service';
|
||||
import { RouterService } from './router.service';
|
||||
import { UnauthGuardService } from './unauth-guard.service';
|
||||
|
||||
import { AuthGuardService } from 'jslib/angular/services/auth-guard.service';
|
||||
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
|
||||
@ -138,6 +139,7 @@ export function initFactory(): Function {
|
||||
ValidationService,
|
||||
AuthGuardService,
|
||||
UnauthGuardService,
|
||||
RouterService,
|
||||
{ provide: AuditServiceAbstraction, useValue: auditService },
|
||||
{ provide: AuthServiceAbstraction, useValue: authService },
|
||||
{ provide: CipherServiceAbstraction, useValue: cipherService },
|
Loading…
Reference in New Issue
Block a user