Files
tvone-api/src/module/profile/profile.controller.ts
T
2026-04-17 14:53:21 +01:00

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,
};
}
}