Add user and auth tests
This commit is contained in:
parent
72d7b22891
commit
4bc3be87b4
15 changed files with 288 additions and 26 deletions
|
|
@ -8,6 +8,7 @@ import type {
|
|||
ILoginResponseSuccess,
|
||||
} from "./types.js";
|
||||
import { loginUser, registerUser } from "../../services/auth/auth.js";
|
||||
import { API_ERROR } from "../errors.js";
|
||||
|
||||
const postRegister = async (request: FastifyRequest, _reply: FastifyReply) => {
|
||||
const { username, password, email } = request.body as IRegisterRequest;
|
||||
|
|
@ -20,7 +21,7 @@ const postRegister = async (request: FastifyRequest, _reply: FastifyReply) => {
|
|||
|
||||
if (!newUser) {
|
||||
return {
|
||||
error: "user already exists",
|
||||
error: API_ERROR.USER_ALREADY_EXISTS,
|
||||
} as IRegisterResponseError;
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ const postLogin = async (request: FastifyRequest, _reply: FastifyReply) => {
|
|||
if (!session) {
|
||||
return {
|
||||
username: username,
|
||||
error: "incorrect credentials",
|
||||
error: API_ERROR.ACCESS_DENIED,
|
||||
} as ILoginResponseError;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue