Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement getUserProfile grpc #23

Closed
wants to merge 0 commits into from
Closed

Implement getUserProfile grpc #23

wants to merge 0 commits into from

Conversation

Arnan-Dee
Copy link
Contributor

@Arnan-Dee Arnan-Dee commented Nov 7, 2023

This is how to invoke a gRPC method to getUserProfile
image

This is gRPC request/response look like

message GetUserProfileRequest {
  string access_token = 1;
}


message GetUserProfileResponse {
  string id = 1;
  string firstName = 2;
  string lastName = 3;
  string email = 4;
  string photoURL = 5;
  string role = 6;
  string sportAreaId = 7;

}

Comment on lines 20 to 22
string access_token = 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use user_id instead of access_token since we already have it on gateway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

Comment on lines 106 to 135
public async getUserProfile(request: GetUserProfileRequest): Promise<GetUserProfileResponse> {
try {

let credential = this.jwtService.decode(
request.accessToken,
) as JwtPayload;
let userId = credential.sub;
let user = await this.userRepo.findUserById(userId);
let userSportArea = await this.sportAreaListRepo.findSportAreaOfUser(userId)
return {
id: user.id,
firstName: user.firstName,
lastName: user.lastName,
email: user.email,
photoURL: user.photoURL,
role: user.role,
sportAreaId: ((userSportArea == null) ? null : userSportArea.SportAreaId),
}

} catch (err: any) {
console.log(err);
if (!(err instanceof RpcException)) {
throw new RpcException({
code: status.INTERNAL,
message: 'internal server error cant get user profile',
});
}
throw err;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to call fileService to retrieve profileUrl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants