parent
d23ed002b2
commit
28c2b862f0
@ -3,6 +3,7 @@ import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
|
|||||||
import { InvalidCredentialsError, PasswordNeededError, UsernameOrEmailNeededError } from '../errors/AuthError';
|
import { InvalidCredentialsError, PasswordNeededError, UsernameOrEmailNeededError } from '../errors/AuthError';
|
||||||
import { UserNotFoundError } from '../errors/UserErrors';
|
import { UserNotFoundError } from '../errors/UserErrors';
|
||||||
import { CreateAuth } from '../models/creation/CreateAuth';
|
import { CreateAuth } from '../models/creation/CreateAuth';
|
||||||
|
import { RefreshAuth } from '../models/creation/RefreshAuth';
|
||||||
|
|
||||||
@JsonController('/auth')
|
@JsonController('/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
@ -16,7 +17,7 @@ export class AuthController {
|
|||||||
@ResponseSchema(PasswordNeededError)
|
@ResponseSchema(PasswordNeededError)
|
||||||
@ResponseSchema(InvalidCredentialsError)
|
@ResponseSchema(InvalidCredentialsError)
|
||||||
@OpenAPI({ description: 'Create a new access token object' })
|
@OpenAPI({ description: 'Create a new access token object' })
|
||||||
async post(@Body({ validate: true }) createAuth: CreateAuth) {
|
async login(@Body({ validate: true }) createAuth: CreateAuth) {
|
||||||
let auth;
|
let auth;
|
||||||
try {
|
try {
|
||||||
auth = await createAuth.toAuth();
|
auth = await createAuth.toAuth();
|
||||||
@ -26,4 +27,19 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
return auth
|
return auth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post("/refresh")
|
||||||
|
@ResponseSchema(InvalidCredentialsError)
|
||||||
|
@ResponseSchema(UserNotFoundError)
|
||||||
|
@OpenAPI({ description: 'refresh a access token' })
|
||||||
|
async refresh(@Body({ validate: true }) refreshAuth: RefreshAuth) {
|
||||||
|
let auth;
|
||||||
|
try {
|
||||||
|
auth = await refreshAuth.toAuth();
|
||||||
|
console.log(auth);
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
return auth
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user