diff options
Diffstat (limited to 'client/src/app/core/auth/auth.service.ts')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 614d38d08..363f58155 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs' | 1 | import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs' |
2 | import { catchError, map, mergeMap, tap, share } from 'rxjs/operators' | 2 | 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' |
@@ -13,6 +13,7 @@ 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 | 17 | ||
17 | interface UserLoginWithUsername extends UserLogin { | 18 | interface UserLoginWithUsername extends UserLogin { |
18 | access_token: string | 19 | access_token: string |
@@ -46,7 +47,8 @@ export class AuthService { | |||
46 | private http: HttpClient, | 47 | private http: HttpClient, |
47 | private notificationsService: NotificationsService, | 48 | private notificationsService: NotificationsService, |
48 | private restExtractor: RestExtractor, | 49 | private restExtractor: RestExtractor, |
49 | private router: Router | 50 | private router: Router, |
51 | private i18n: I18n | ||
50 | ) { | 52 | ) { |
51 | this.loginChanged = new Subject<AuthStatus>() | 53 | this.loginChanged = new Subject<AuthStatus>() |
52 | this.loginChangedSource = this.loginChanged.asObservable() | 54 | this.loginChangedSource = this.loginChanged.asObservable() |
@@ -74,14 +76,15 @@ export class AuthService { | |||
74 | let errorMessage = error.message | 76 | let errorMessage = error.message |
75 | 77 | ||
76 | if (error.status === 403) { | 78 | if (error.status === 403) { |
77 | errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n` | 79 | errorMessage = this.i18n('Cannot retrieve OAuth Client credentials: {{ errorText }}.\n', { errorText: error.text }) |
78 | errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), ' + | 80 | errorMessage += this.i18n( |
79 | 'in particular the "webserver" section.' | 81 | 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.' |
82 | ) | ||
80 | } | 83 | } |
81 | 84 | ||
82 | // We put a bigger timeout | 85 | // We put a bigger timeout |
83 | // This is an important message | 86 | // This is an important message |
84 | this.notificationsService.error('Error', errorMessage, { timeOut: 7000 }) | 87 | this.notificationsService.error(this.i18n('Error'), errorMessage, { timeOut: 7000 }) |
85 | } | 88 | } |
86 | ) | 89 | ) |
87 | } | 90 | } |
@@ -180,7 +183,7 @@ export class AuthService { | |||
180 | this.router.navigate([ '/login' ]) | 183 | this.router.navigate([ '/login' ]) |
181 | 184 | ||
182 | return observableThrowError({ | 185 | return observableThrowError({ |
183 | error: 'You need to reconnect.' | 186 | error: this.i18n('You need to reconnect.') |
184 | }) | 187 | }) |
185 | }), | 188 | }), |
186 | share() | 189 | share() |