|
@@ -13,16 +13,19 @@ import {
|
|
|
LoginInput
|
|
LoginInput
|
|
|
} from "./types";
|
|
} from "./types";
|
|
|
import redis from "../../../config/redis";
|
|
import redis from "../../../config/redis";
|
|
|
|
|
+import {
|
|
|
|
|
+ formatValidationErrors
|
|
|
|
|
+} from "../../../utils";
|
|
|
|
|
|
|
|
export const login = async (input: LoginInput): Promise<LoginResult> => {
|
|
export const login = async (input: LoginInput): Promise<LoginResult> => {
|
|
|
const dto = plainToInstance(LoginInput, input);
|
|
const dto = plainToInstance(LoginInput, input);
|
|
|
const errors = await validate(dto);
|
|
const errors = await validate(dto);
|
|
|
|
|
|
|
|
if (errors.length > 0) {
|
|
if (errors.length > 0) {
|
|
|
- const message = Object.values(errors[0].constraints!)[0];
|
|
|
|
|
|
|
+ const formattedErrors = formatValidationErrors(errors);
|
|
|
return {
|
|
return {
|
|
|
code: 400,
|
|
code: 400,
|
|
|
- message,
|
|
|
|
|
|
|
+ message: formattedErrors[0],
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|