aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/auth')
-rw-r--r--client/src/app/core/auth/auth.service.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index df6e5135b..913c857e3 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -3,6 +3,8 @@ import { Router } from '@angular/router'
3import { Observable } from 'rxjs/Observable' 3import { Observable } from 'rxjs/Observable'
4import { Subject } from 'rxjs/Subject' 4import { Subject } from 'rxjs/Subject'
5import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' 5import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
6import { ReplaySubject } from 'rxjs/ReplaySubject'
7import 'rxjs/add/operator/do'
6import 'rxjs/add/operator/map' 8import 'rxjs/add/operator/map'
7import 'rxjs/add/operator/mergeMap' 9import 'rxjs/add/operator/mergeMap'
8import 'rxjs/add/observable/throw' 10import 'rxjs/add/observable/throw'
@@ -54,6 +56,7 @@ export class AuthService {
54 private static BASE_USER_INFORMATION_URL = API_URL + '/api/v1/users/me' 56 private static BASE_USER_INFORMATION_URL = API_URL + '/api/v1/users/me'
55 57
56 loginChangedSource: Observable<AuthStatus> 58 loginChangedSource: Observable<AuthStatus>
59 userInformationLoaded = new ReplaySubject<boolean>(1)
57 60
58 private clientId: string 61 private clientId: string
59 private clientSecret: string 62 private clientSecret: string
@@ -199,16 +202,17 @@ export class AuthService {
199 } 202 }
200 203
201 this.mergeUserInformation(obj) 204 this.mergeUserInformation(obj)
202 .subscribe( 205 .do(() => this.userInformationLoaded.next(true))
203 res => { 206 .subscribe(
204 this.user.displayNSFW = res.displayNSFW 207 res => {
205 this.user.role = res.role 208 this.user.displayNSFW = res.displayNSFW
206 this.user.videoChannels = res.videoChannels 209 this.user.role = res.role
207 this.user.author = res.author 210 this.user.videoChannels = res.videoChannels
208 211 this.user.author = res.author
209 this.user.save() 212
210 } 213 this.user.save()
211 ) 214 }
215 )
212 } 216 }
213 217
214 private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> { 218 private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> {