Files
twenty/server/src/core/auth/controllers/token.controller.ts
Jérémy M 299ca293a8 feat: refactoring auth & add email password login (#318)
* feat: wip

* fix: issues

* feat: clean controllers and services

* fix: test

* Fix auth

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-06-17 13:42:02 +02:00

22 lines
634 B
TypeScript

import { BadRequestException, Body, Controller, Post } from '@nestjs/common';
import { RefreshTokenInput } from '../dto/refresh-token.input';
import { TokenService } from '../services/token.service';
@Controller('auth/token')
export class TokenController {
constructor(private tokenService: TokenService) {}
@Post()
async generateAccessToken(@Body() body: RefreshTokenInput) {
if (!body.refreshToken) {
throw new BadRequestException('Refresh token is mendatory');
}
const tokens = await this.tokenService.generateTokensFromRefreshToken(
body.refreshToken,
);
return { tokens: tokens };
}
}