mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-08 15:14:48 +00:00
28 lines
651 B
TypeScript
28 lines
651 B
TypeScript
import { Body, Controller, Post, UnauthorizedException } from '@nestjs/common';
|
|
|
|
import { AuthClientService } from 'src/clients/auth/client.service';
|
|
|
|
interface ISignIn {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private authClient: AuthClientService) {}
|
|
|
|
@Post()
|
|
async signIn(@Body() { username, password }: ISignIn) {
|
|
console.log(`/auth`, 'SignIn');
|
|
|
|
const tokens = await this.authClient
|
|
.signIn({ username, password })
|
|
.then((result) => result)
|
|
.catch((err) => {
|
|
throw new UnauthorizedException(err.message);
|
|
});
|
|
|
|
return tokens;
|
|
}
|
|
}
|