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

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

@ -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 "??? ???";
} }

Loading…
Cancel
Save