Skip to content

Commit ac33928

Browse files
Add support for /v4/user-from-token in FE - to be connected where needed later
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent c9d98d8 commit ac33928

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/app/core/models/user.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ export class UserModel {
1919
version: string;
2020
}
2121

22+
export class UserFromTokenModel {
23+
userID: string;
24+
userExternalID?: string;
25+
username?: string;
26+
dateCreated?: string | Date;
27+
dateModified?: string | Date;
28+
lfEmail?: string;
29+
lfUsername?: string;
30+
companyID?: string;
31+
githubID?: string;
32+
githubUsername?: string;
33+
gitlabID?: string;
34+
gitlabUsername?: string;
35+
admin?: boolean;
36+
version?: string;
37+
note?: string;
38+
emails?: string[];
39+
userCompanyID?: string;
40+
isSanctioned?: boolean;
41+
}
42+
2243
export class UpdateUserModel {
2344
companyID: string;
2445
dateCreated: Date;

src/app/core/services/cla-contributor.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class ClaContributorService {
6060
return this.httpClient.get<UserModel>(url);
6161
}
6262

63+
getUserFromToken(): Observable<UserFromTokenModel> {
64+
const url = this.getV4Endpoint('/v4/user-from-token');
65+
return this.httpClient.get<UserFromTokenModel>(url);
66+
}
67+
6368
updateUser(data: any): Observable<UpdateUserModel> {
6469
const url = this.getV3Endpoint('/v3/users');
6570
return this.httpClient.put<UpdateUserModel>(url, data);

src/app/shared/components/project-title/project-title.component.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ export class ProjectTitleComponent implements AfterViewInit {
6464
}
6565
}
6666

67+
getUserFromToken() {
68+
this.claContributorService.getUserFromToken().subscribe(
69+
(response) => {
70+
this.user = response;
71+
this.storageService.setItem(AppSettings.USER_ID, this.user.userID);
72+
this.storageService.setItem(AppSettings.USER, this.user);
73+
},
74+
(exception) => {
75+
this.errorEmitter.emit(true);
76+
this.claContributorService.handleError(exception);
77+
}
78+
);
79+
}
6780

6881
getUser() {
6982
const userId = JSON.parse(this.storageService.getItem(AppSettings.USER_ID));
@@ -84,4 +97,4 @@ export class ProjectTitleComponent implements AfterViewInit {
8497
this.alertService.error('There is an invalid user ID in the URL');
8598
}
8699
}
87-
}
100+
}

0 commit comments

Comments
 (0)