diff options
Diffstat (limited to 'client/src/app/core/auth/auth.service.ts')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 9c36b946e..eaa822e0f 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -3,18 +3,18 @@ import { catchError, map, mergeMap, share, tap } from 'rxjs/operators' | |||
3 | import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { Router } from '@angular/router' | 5 | import { Router } from '@angular/router' |
6 | import { NotificationsService } from 'angular2-notifications' | 6 | import { Notifier } from '@app/core/notification/notifier.service' |
7 | import { OAuthClientLocal, User as UserServerModel, UserRefreshToken } from '../../../../../shared' | 7 | import { OAuthClientLocal, User as UserServerModel, UserRefreshToken } from '../../../../../shared' |
8 | import { User } from '../../../../../shared/models/users' | 8 | import { User } from '../../../../../shared/models/users' |
9 | import { UserLogin } from '../../../../../shared/models/users/user-login.model' | 9 | import { UserLogin } from '../../../../../shared/models/users/user-login.model' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../../shared/rest' | 11 | import { RestExtractor } from '../../shared/rest/rest-extractor.service' |
12 | import { AuthStatus } from './auth-status.model' | 12 | import { AuthStatus } from './auth-status.model' |
13 | import { AuthUser } from './auth-user.model' | 13 | import { AuthUser } from './auth-user.model' |
14 | import { objectToUrlEncoded } from '@app/shared/misc/utils' | 14 | import { objectToUrlEncoded } from '@app/shared/misc/utils' |
15 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | 15 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' |
16 | import { I18n } from '@ngx-translate/i18n-polyfill' | 16 | import { I18n } from '@ngx-translate/i18n-polyfill' |
17 | import { HotkeysService, Hotkey } from 'angular2-hotkeys' | 17 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
18 | 18 | ||
19 | interface UserLoginWithUsername extends UserLogin { | 19 | interface UserLoginWithUsername extends UserLogin { |
20 | access_token: string | 20 | access_token: string |
@@ -38,7 +38,6 @@ 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 | ||
42 | 41 | ||
43 | private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) | 42 | private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) |
44 | private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) | 43 | private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) |
@@ -48,7 +47,7 @@ export class AuthService { | |||
48 | 47 | ||
49 | constructor ( | 48 | constructor ( |
50 | private http: HttpClient, | 49 | private http: HttpClient, |
51 | private notificationsService: NotificationsService, | 50 | private notifier: Notifier, |
52 | private hotkeysService: HotkeysService, | 51 | private hotkeysService: HotkeysService, |
53 | private restExtractor: RestExtractor, | 52 | private restExtractor: RestExtractor, |
54 | private router: Router, | 53 | private router: Router, |
@@ -106,9 +105,8 @@ export class AuthService { | |||
106 | ) | 105 | ) |
107 | } | 106 | } |
108 | 107 | ||
109 | // We put a bigger timeout | 108 | // We put a bigger timeout: this is an important message |
110 | // This is an important message | 109 | this.notifier.error(errorMessage, this.i18n('Error'), 7000) |
111 | this.notificationsService.error(this.i18n('Error'), errorMessage, { timeOut: 7000 }) | ||
112 | } | 110 | } |
113 | ) | 111 | ) |
114 | } | 112 | } |
@@ -178,8 +176,6 @@ export class AuthService { | |||
178 | this.setStatus(AuthStatus.LoggedOut) | 176 | this.setStatus(AuthStatus.LoggedOut) |
179 | 177 | ||
180 | this.hotkeysService.remove(this.hotkeys) | 178 | this.hotkeysService.remove(this.hotkeys) |
181 | |||
182 | this.redirectUrl = null | ||
183 | } | 179 | } |
184 | 180 | ||
185 | refreshAccessToken () { | 181 | refreshAccessToken () { |
@@ -221,7 +217,7 @@ export class AuthService { | |||
221 | } | 217 | } |
222 | 218 | ||
223 | refreshUserInformation () { | 219 | refreshUserInformation () { |
224 | const obj = { | 220 | const obj: UserLoginWithUsername = { |
225 | access_token: this.user.getAccessToken(), | 221 | access_token: this.user.getAccessToken(), |
226 | refresh_token: null, | 222 | refresh_token: null, |
227 | token_type: this.user.getTokenType(), | 223 | token_type: this.user.getTokenType(), |