@@ -3,6 +3,7 @@ import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
||||
import { IllegalJWTError, InvalidCredentialsError, JwtNotProvidedError, PasswordNeededError, RefreshTokenCountInvalidError, UsernameOrEmailNeededError } from '../errors/AuthError';
|
||||
import { UserNotFoundError } from '../errors/UserErrors';
|
||||
import { CreateAuth } from '../models/creation/CreateAuth';
|
||||
import { HandleLogout } from '../models/creation/HandleLogout';
|
||||
import { RefreshAuth } from '../models/creation/RefreshAuth';
|
||||
|
||||
@JsonController('/auth')
|
||||
@@ -28,6 +29,24 @@ export class AuthController {
|
||||
return auth
|
||||
}
|
||||
|
||||
@Post("/logout")
|
||||
@ResponseSchema(InvalidCredentialsError)
|
||||
@ResponseSchema(UserNotFoundError)
|
||||
@ResponseSchema(UsernameOrEmailNeededError)
|
||||
@ResponseSchema(PasswordNeededError)
|
||||
@ResponseSchema(InvalidCredentialsError)
|
||||
@OpenAPI({ description: 'Create a new access token object' })
|
||||
async logout(@Body({ validate: true }) handleLogout: HandleLogout) {
|
||||
let logout;
|
||||
try {
|
||||
logout = await handleLogout.logout()
|
||||
console.log(logout);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return logout
|
||||
}
|
||||
|
||||
@Post("/refresh")
|
||||
@ResponseSchema(JwtNotProvidedError)
|
||||
@ResponseSchema(IllegalJWTError)
|
||||
|
||||
Reference in New Issue
Block a user