diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 3 | ||||
-rw-r--r-- | client/src/app/core/routing/login-guard.service.ts | 2 | ||||
-rw-r--r-- | client/src/app/login/login.component.ts | 13 |
3 files changed, 17 insertions, 1 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 88ea89639..8ff5713a1 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -38,6 +38,7 @@ export class AuthService { | |||
38 | loginChangedSource: Observable<AuthStatus> | 38 | loginChangedSource: Observable<AuthStatus> |
39 | userInformationLoaded = new ReplaySubject<boolean>(1) | 39 | userInformationLoaded = new ReplaySubject<boolean>(1) |
40 | hotkeys: Hotkey[] | 40 | hotkeys: Hotkey[] |
41 | redirectUrl: string | ||
41 | 42 | ||
42 | private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) | 43 | private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) |
43 | private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) | 44 | private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) |
@@ -177,6 +178,8 @@ export class AuthService { | |||
177 | this.setStatus(AuthStatus.LoggedOut) | 178 | this.setStatus(AuthStatus.LoggedOut) |
178 | 179 | ||
179 | this.hotkeysService.remove(this.hotkeys) | 180 | this.hotkeysService.remove(this.hotkeys) |
181 | |||
182 | this.redirectUrl = null | ||
180 | } | 183 | } |
181 | 184 | ||
182 | refreshAccessToken () { | 185 | refreshAccessToken () { |
diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts index 18bc41ca6..40ff8f505 100644 --- a/client/src/app/core/routing/login-guard.service.ts +++ b/client/src/app/core/routing/login-guard.service.ts | |||
@@ -20,6 +20,8 @@ export class LoginGuard implements CanActivate, CanActivateChild { | |||
20 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | 20 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { |
21 | if (this.auth.isLoggedIn() === true) return true | 21 | if (this.auth.isLoggedIn() === true) return true |
22 | 22 | ||
23 | this.auth.redirectUrl = state.url | ||
24 | |||
23 | this.router.navigate([ '/login' ]) | 25 | this.router.navigate([ '/login' ]) |
24 | return false | 26 | return false |
25 | } | 27 | } |
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 4bae3ae5c..7553e6456 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -8,6 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
9 | import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' | 9 | import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' |
10 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | 10 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' |
11 | import { Router } from '@angular/router' | ||
11 | 12 | ||
12 | @Component({ | 13 | @Component({ |
13 | selector: 'my-login', | 14 | selector: 'my-login', |
@@ -26,6 +27,7 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
26 | private openedForgotPasswordModal: NgbModalRef | 27 | private openedForgotPasswordModal: NgbModalRef |
27 | 28 | ||
28 | constructor ( | 29 | constructor ( |
30 | public router: Router, | ||
29 | protected formValidatorService: FormValidatorService, | 31 | protected formValidatorService: FormValidatorService, |
30 | private modalService: NgbModal, | 32 | private modalService: NgbModal, |
31 | private loginValidatorsService: LoginValidatorsService, | 33 | private loginValidatorsService: LoginValidatorsService, |
@@ -59,7 +61,7 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
59 | 61 | ||
60 | this.authService.login(username, password) | 62 | this.authService.login(username, password) |
61 | .subscribe( | 63 | .subscribe( |
62 | () => this.redirectService.redirectToHomepage(), | 64 | () => this.redirect(), |
63 | 65 | ||
64 | err => { | 66 | err => { |
65 | if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') | 67 | if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') |
@@ -69,6 +71,15 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
69 | ) | 71 | ) |
70 | } | 72 | } |
71 | 73 | ||
74 | redirect () { | ||
75 | const redirect = this.authService.redirectUrl | ||
76 | if (redirect) { | ||
77 | this.router.navigate([ redirect ]) | ||
78 | } else { | ||
79 | this.redirectService.redirectToHomepage() | ||
80 | } | ||
81 | } | ||
82 | |||
72 | askResetPassword () { | 83 | askResetPassword () { |
73 | this.userService.askResetPassword(this.forgotPasswordEmail) | 84 | this.userService.askResetPassword(this.forgotPasswordEmail) |
74 | .subscribe( | 85 | .subscribe( |