Skip to content

Commit

Permalink
Replace login and join action function using @conform-to
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterEckIII committed May 15, 2023
1 parent a83726e commit 6c7dfc6
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 218 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

## Database

This project uses sqlite to store data. Anytime you change the `prisma/schema.prisma` file you must run `npm run migrate` to migrate the changes to the actual database. (**Note**, _you may also need to run this command when installing new Cypress packages_)
This project uses Postgresql to store data. Anytime you change the `prisma/schema.prisma` file you must run `npm run migrate` to migrate the changes to the actual database. (**Note**, _you may also need to run this command when installing new Cypress packages_)

### Connecting to the database

Expand Down
24 changes: 24 additions & 0 deletions app/models/user.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ export async function deleteUserByEmail(email: user["email"]) {
return prisma.user.delete({ where: { email } });
}

export async function verifyWithUsername(
username: user["username"],
password: password["hash"]
) {
const userWithPassword = await prisma.user.findUnique({
where: { username },
include: { password: true },
});

if (!userWithPassword || !userWithPassword.password) {
return null;
}

const isValid = await bcrypt.compare(
password,
userWithPassword.password.hash
);
if (!isValid) return null;

const { password: _password, ...userWithoutPassword } = userWithPassword;

return userWithoutPassword;
}

export async function verifyLogin(
email: user["email"],
password: password["hash"]
Expand Down
Loading

0 comments on commit 6c7dfc6

Please sign in to comment.