mirror of
https://github.com/PeterMaquiran/tvone-api.git
synced 2026-04-21 19:50:46 +00:00
25 lines
696 B
TypeScript
25 lines
696 B
TypeScript
import { KeycloakAuthGuard } from '../auth/keycloak.guard';
|
|
import { ProfileService } from './profile.service';
|
|
import { Controller, Get, UseGuards, Request } from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
|
|
|
|
@Controller('profile')
|
|
export class ProfileController {
|
|
constructor(private readonly profileService: ProfileService) {}
|
|
|
|
@UseGuards(AuthGuard('keycloak'))
|
|
@Get()
|
|
getProfile(@Request() req) {
|
|
// The 'user' object here is exactly what you returned from validate()
|
|
|
|
return {
|
|
email: req.user.email,
|
|
name: req.user.name,
|
|
picture: req.user.picture,
|
|
email_verified: req.user.email_verified,
|
|
roles: req.user.roles,
|
|
};
|
|
}
|
|
}
|