Add user and auth tests
This commit is contained in:
parent
72d7b22891
commit
4bc3be87b4
15 changed files with 288 additions and 26 deletions
|
|
@ -9,12 +9,20 @@ import { getJwtSecret } from "./helpers.js";
|
|||
const registerUser = async (
|
||||
registration: IUserRegistration,
|
||||
): Promise<User | null> => {
|
||||
const existingUser = await getDB().user.findUnique({
|
||||
const existingUserUsername = await getDB().user.findUnique({
|
||||
where: { username: registration.username },
|
||||
});
|
||||
if (existingUser) {
|
||||
if (existingUserUsername) {
|
||||
return null;
|
||||
}
|
||||
if (registration.email) {
|
||||
const existingUserEmail = await getDB().user.findUnique({
|
||||
where: { email: registration.email },
|
||||
});
|
||||
if (existingUserEmail) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(registration.password);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue