23 lines
730 B
TypeScript
23 lines
730 B
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|||
|
|
import { CurrentUser } from '../auth/current-user.decorator';
|
||
|
|
import { PlatformLoginDto } from './dto';
|
||
|
|
import { PlatformAuthGuard } from './platform-auth.guard';
|
||
|
|
import { PlatformAuthService } from './platform-auth.service';
|
||
|
|
import type { PlatformActor } from './platform-jwt.strategy';
|
||
|
|
|
||
|
|
@Controller('platform/auth')
|
||
|
|
export class PlatformAuthController {
|
||
|
|
constructor(private readonly auth: PlatformAuthService) {}
|
||
|
|
|
||
|
|
@Post('login')
|
||
|
|
login(@Body() dto: PlatformLoginDto) {
|
||
|
|
return this.auth.login(dto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Get('me')
|
||
|
|
@UseGuards(PlatformAuthGuard)
|
||
|
|
me(@CurrentUser() actor: PlatformActor) {
|
||
|
|
return this.auth.me(actor.platformAdminId);
|
||
|
|
}
|
||
|
|
}
|