Add user first and last name fields to signup form

This commit is contained in:
Sean Morley
2024-04-03 22:59:05 +00:00
parent 372db59211
commit ba6a5283fe
12 changed files with 273 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { visitCount } from "$lib/utils/stores/visitCountStore";
import { goto } from "$app/navigation";
import type { DatabaseUser } from "$lib/server/auth";
async function goHome() {
goto("/");
}

View File

@@ -21,6 +21,8 @@ export const sharedAdventures = pgTable("sharedAdventures", {
export const userTable = pgTable("user", {
id: text("id").primaryKey(),
username: text("username").notNull(),
first_name: text("first_name").notNull(),
last_name: text("last_name").notNull(),
hashed_password: varchar("hashed_password").notNull(),
});

View File

@@ -1,9 +1,8 @@
import { DrizzlePostgreSQLAdapter } from "@lucia-auth/adapter-drizzle";
import { Lucia } from "lucia";
import { Lucia, TimeSpan } from "lucia";
import { dev } from "$app/environment";
import { userTable, sessionTable } from "$lib/db/schema";
import { db } from "$lib/db/db.server";
import { Argon2id } from "oslo/password";
const adapter = new DrizzlePostgreSQLAdapter(db, sessionTable, userTable);
@@ -17,6 +16,9 @@ export const lucia = new Lucia(adapter, {
return {
// attributes has the type of DatabaseUserAttributes
username: attributes.username,
id: attributes.id,
first_name: attributes.first_name,
last_name: attributes.last_name,
};
},
});
@@ -24,15 +26,14 @@ export const lucia = new Lucia(adapter, {
declare module "lucia" {
interface Register {
Lucia: typeof lucia;
DatabaseUserAttributes: DatabaseUserAttributes;
DatabaseUserAttributes: DatabaseUser;
}
}
interface DatabaseUserAttributes {
username: string;
}
export interface DatabaseUser {
id: string;
username: string;
first_name: string;
last_name: string;
hashed_password: string;
}