aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+login/login.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+login/login.component.ts')
-rw-r--r--client/src/app/+login/login.component.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts
index 648b8db36..73bd41ab4 100644
--- a/client/src/app/+login/login.component.ts
+++ b/client/src/app/+login/login.component.ts
@@ -1,7 +1,7 @@
1 1
2import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' 2import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute } from '@angular/router' 3import { ActivatedRoute } from '@angular/router'
4import { AuthService, Notifier, RedirectService, UserService } from '@app/core' 4import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core'
5import { HooksService } from '@app/core/plugins/hooks.service' 5import { HooksService } from '@app/core/plugins/hooks.service'
6import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' 6import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' 7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@@ -17,6 +17,8 @@ import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
17}) 17})
18 18
19export class LoginComponent extends FormReactive implements OnInit, AfterViewInit { 19export class LoginComponent extends FormReactive implements OnInit, AfterViewInit {
20 private static SESSION_STORAGE_REDIRECT_URL_KEY = 'login-previous-url'
21
20 @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef 22 @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef
21 23
22 accordion: NgbAccordion 24 accordion: NgbAccordion
@@ -46,7 +48,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
46 private userService: UserService, 48 private userService: UserService,
47 private redirectService: RedirectService, 49 private redirectService: RedirectService,
48 private notifier: Notifier, 50 private notifier: Notifier,
49 private hooks: HooksService 51 private hooks: HooksService,
52 private storage: SessionStorageService
50 ) { 53 ) {
51 super() 54 super()
52 } 55 }
@@ -88,6 +91,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
88 this.externalAuthError = true 91 this.externalAuthError = true
89 return 92 return
90 } 93 }
94
95 this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, this.redirectService.getPreviousUrl())
91 } 96 }
92 97
93 ngAfterViewInit () { 98 ngAfterViewInit () {
@@ -151,7 +156,9 @@ The link will expire within 1 hour.`
151 156
152 this.authService.login(username, null, token) 157 this.authService.login(username, null, token)
153 .subscribe({ 158 .subscribe({
154 next: () => this.redirectService.redirectToPreviousRoute(), 159 next: () => {
160 this.redirectService.redirectToPreviousRoute(this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY))
161 },
155 162
156 error: err => { 163 error: err => {
157 this.handleError(err) 164 this.handleError(err)