|
|
@ -12,7 +12,7 @@ export class UsersService { |
|
|
|
|
|
|
|
|
isAuthenticated = false; |
|
|
isAuthenticated = false; |
|
|
permissions: string[] = []; |
|
|
permissions: string[] = []; |
|
|
user: User | null | undefined = null; |
|
|
localUser: User | null | undefined = null; |
|
|
additionalInfo : any = null; |
|
|
additionalInfo : any = null; |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
@ -33,8 +33,8 @@ export class UsersService { |
|
|
if(!this.isAuthenticated) { return } |
|
|
if(!this.isAuthenticated) { return } |
|
|
|
|
|
|
|
|
this.authService.user$.subscribe(data => { |
|
|
this.authService.user$.subscribe(data => { |
|
|
this.user = data; |
|
|
this.localUser = data; |
|
|
console.log(this.user); |
|
|
console.log(this.localUser); |
|
|
this.reportLogin(); |
|
|
this.reportLogin(); |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
@ -51,40 +51,40 @@ export class UsersService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
reportLogin() { |
|
|
reportLogin() { |
|
|
if(!this.user) { return } |
|
|
if(!this.localUser) { return } |
|
|
let id = this.user.sub; |
|
|
let id = this.localUser.sub; |
|
|
let nickname = this.user.nickname; |
|
|
let nickname = this.localUser.nickname; |
|
|
let picture = this.user.picture; |
|
|
let picture = this.localUser.picture; |
|
|
let time = Date.now(); |
|
|
let time = Date.now(); |
|
|
this.httpClient.post(this.serverEndpointService.getCurrentEndpoint()+"users/login", {id, nickname, picture, time}).subscribe(); |
|
|
this.httpClient.post(this.serverEndpointService.getCurrentEndpoint()+"users/login", {id, nickname, picture, time}).subscribe(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getUserName() : string { |
|
|
getUserName() : string { |
|
|
if(!this.isAuthenticated || !this.user) {return ""} |
|
|
if(!this.isAuthenticated || !this.localUser) {return ""} |
|
|
|
|
|
|
|
|
return this.user.nickname || ""; |
|
|
return this.localUser.nickname || ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getUserId() : string { |
|
|
getUserId() : string { |
|
|
if(!this.isAuthenticated || !this.user) {return ""} |
|
|
if(!this.isAuthenticated || !this.localUser) {return ""} |
|
|
|
|
|
|
|
|
return this.user.sub?.replace("auth0|", "") || ""; |
|
|
return this.localUser.sub?.replace("auth0|", "") || ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getUserPicture() : string { |
|
|
getUserPicture() : string { |
|
|
if(!this.isAuthenticated || !this.user) {return ""} |
|
|
if(!this.isAuthenticated || !this.localUser) {return ""} |
|
|
|
|
|
|
|
|
return this.user.picture || ""; |
|
|
return this.localUser.picture || ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getUserEmail() : string { |
|
|
getUserEmail() : string { |
|
|
if(!this.isAuthenticated || !this.user) {return ""} |
|
|
if(!this.isAuthenticated || !this.localUser) {return ""} |
|
|
|
|
|
|
|
|
return this.user.email || ""; |
|
|
return this.localUser.email || ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getUserRealName() : string { |
|
|
getUserRealName() : string { |
|
|
if(!this.isAuthenticated || !this.user || !this.additionalInfo) {return "??? ???"} |
|
|
if(!this.isAuthenticated || !this.localUser || !this.additionalInfo) {return "??? ???"} |
|
|
|
|
|
|
|
|
return "??? ???"; |
|
|
return "??? ???"; |
|
|
} |
|
|
} |
|
|
|