diff options
Diffstat (limited to 'client/src/app/+login')
-rw-r--r-- | client/src/app/+login/login.component.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts index 73bd41ab4..96754b782 100644 --- a/client/src/app/+login/login.component.ts +++ b/client/src/app/+login/login.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 2 | import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' | 4 | import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' |
5 | import { HooksService } from '@app/core/plugins/hooks.service' | 5 | import { HooksService } from '@app/core/plugins/hooks.service' |
6 | import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' | 6 | import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' |
@@ -49,7 +49,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni | |||
49 | private redirectService: RedirectService, | 49 | private redirectService: RedirectService, |
50 | private notifier: Notifier, | 50 | private notifier: Notifier, |
51 | private hooks: HooksService, | 51 | private hooks: HooksService, |
52 | private storage: SessionStorageService | 52 | private storage: SessionStorageService, |
53 | private router: Router | ||
53 | ) { | 54 | ) { |
54 | super() | 55 | super() |
55 | } | 56 | } |
@@ -92,7 +93,10 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni | |||
92 | return | 93 | return |
93 | } | 94 | } |
94 | 95 | ||
95 | this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, this.redirectService.getPreviousUrl()) | 96 | const previousUrl = this.redirectService.getPreviousUrl() |
97 | if (previousUrl && previousUrl !== '/') { | ||
98 | this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, previousUrl) | ||
99 | } | ||
96 | } | 100 | } |
97 | 101 | ||
98 | ngAfterViewInit () { | 102 | ngAfterViewInit () { |
@@ -157,7 +161,13 @@ The link will expire within 1 hour.` | |||
157 | this.authService.login(username, null, token) | 161 | this.authService.login(username, null, token) |
158 | .subscribe({ | 162 | .subscribe({ |
159 | next: () => { | 163 | next: () => { |
160 | this.redirectService.redirectToPreviousRoute(this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY)) | 164 | const redirectUrl = this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY) |
165 | if (redirectUrl) { | ||
166 | this.storage.removeItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY) | ||
167 | return this.router.navigateByUrl(redirectUrl) | ||
168 | } | ||
169 | |||
170 | this.redirectService.redirectToLatestSessionRoute() | ||
161 | }, | 171 | }, |
162 | 172 | ||
163 | error: err => { | 173 | error: err => { |