Update visit count and password hashing

This commit is contained in:
Sean Morley
2024-04-10 23:34:48 +00:00
parent 549840128f
commit 70e23b8878
3 changed files with 22 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import type { PageServerLoad } from "./$types";
import { db } from "$lib/db/db.server";
import { userTable } from "$lib/db/schema";
import { eq } from "drizzle-orm";
import { Argon2id } from "oslo/password";
export const load: PageServerLoad = async (event) => {
if (event.locals.user)
@@ -20,6 +21,8 @@ export const actions: Actions = {
let firstName = formData.get("first_name");
let lastName = formData.get("last_name");
let password = formData.get("password");
if (!userId) {
return {
status: 400,
@@ -29,6 +32,16 @@ export const actions: Actions = {
};
}
if (password) {
let hashedPassword = await new Argon2id().hash(password);
console.log(hashedPassword)
await db.update(userTable)
.set({
hashed_password: hashedPassword
})
.where(eq(userTable.id, userId));
}
await db.update(userTable)
.set({
username: username,