get profile by token

This commit is contained in:
Kittapath 2024-05-24 01:11:47 +07:00
parent 58fe2f08fd
commit 85f8fbb03a
5 changed files with 124 additions and 59 deletions

View file

@ -548,6 +548,28 @@ export class ProfileController extends Controller {
return new HttpSuccess();
}
/**
* API
*
* @summary ORG_065 - (ADMIN) #70
*
* @param {string} id Id
*/
@Get("user")
async getProfileByUser(@Request() request: RequestWithUser) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
/**
* API
*