improve login and add migration script
This commit is contained in:
parent
1fce467571
commit
099ffb74a1
5 changed files with 106 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
UnauthorizedError,
|
||||
InternalServerError,
|
||||
} from "../errors/httpErrors";
|
||||
import { LoginRequestDto } from "../dtos/LoginRequestDto";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
|
@ -16,9 +17,9 @@ const authController = new AuthController(userRepository, mapper);
|
|||
|
||||
router.post("/login", async (req, res) => {
|
||||
try {
|
||||
const { userName, password } = req.body;
|
||||
const result = await authController.login(userName, password);
|
||||
res.json(result);
|
||||
const requestDto: LoginRequestDto = req.body;
|
||||
const responseDto = await authController.login(requestDto));
|
||||
res.json(responseDto);
|
||||
} catch (err: any) {
|
||||
if (err instanceof ValidationError || err instanceof UnauthorizedError) {
|
||||
res.status(err.statusCode).json({ error: err.message });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue