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>
This commit is contained in:
21
server/src/core/auth/controllers/token.controller.ts
Normal file
21
server/src/core/auth/controllers/token.controller.ts
Normal file
@ -0,0 +1,21 @@
|
||||
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 };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user