Browse Source

Prep for other user info

feature/mapper-integration
Quildra 2 years ago
parent
commit
8568eff32f
  1. 11
      packages/bridge-ui/src/app/pages/user/user.component.ts
  2. 32
      packages/bridge-ui/src/app/services/users.service.ts

11
packages/bridge-ui/src/app/pages/user/user.component.ts

@ -8,6 +8,7 @@ import { MatDialog } from '@angular/material/dialog';
import { UsersService } from '../../services/users.service';
import { ClaimRacerDialogComponent } from '../../components/claim-racer-dialog/claim-racer-dialog.component';
import { ActivatedRoute } from '@angular/router';
@Component({
@ -23,13 +24,21 @@ import { ClaimRacerDialogComponent } from '../../components/claim-racer-dialog/c
styleUrl: './user.component.scss'
})
export class UserComponent {
public userId: string = "";
constructor(
public usersService: UsersService,
private dialog: MatDialog,
) {}
private route: ActivatedRoute,
) {
this.userId = String(this.route.snapshot.paramMap.get('id'));
}
openClaimRacerDialog()
{
this.dialog.open(ClaimRacerDialogComponent);
}
}

32
packages/bridge-ui/src/app/services/users.service.ts

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

Loading…
Cancel
Save