working on AuthController + CreateAuth

ref #12
This commit is contained in:
philipp committed 2020-12-04 22:43:41 +01:00
1 parent c4b7ece974
commit 6cb01090d0
2 files changed
+31 -2

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { Body, JsonController, Post } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { InvalidCredentialsError } from '../errors/AuthError';
import { UserNotFoundError } from '../errors/UserErrors';
import { CreateAuth } from '../models/creation/CreateAuth';
@JsonController('/auth')
export class AuthController {
constructor() {
}
@Post("/login")
@ResponseSchema(InvalidCredentialsError)
@ResponseSchema(UserNotFoundError)
@OpenAPI({ description: 'Create a new access token object' })
async post(@Body({ validate: true }) createAuth: CreateAuth) {
let auth;
try {
auth = await createAuth.toAuth();
console.log(auth);
} catch (error) {
return error;
}
return auth
}
}