user creation and invites

This commit is contained in:
2025-06-24 16:31:13 -04:00
parent 23c8f468fe
commit a659401bde
32 changed files with 667 additions and 30 deletions

View File

@@ -15,7 +15,6 @@ export const authOptions: NextAuthOptions = {
},
async authorize(credentials) {
if (!credentials?.email || !credentials?.password) {
console.log('[AUTH] Missing credentials')
return null
}
@@ -24,28 +23,24 @@ export const authOptions: NextAuthOptions = {
})
if (!user) {
console.log('[AUTH] User not found')
return null
}
if (!user.password) {
console.log('[AUTH] User has no password set')
return null
}
const isValid = await bcrypt.compare(credentials.password, user.password)
if (!isValid) {
console.log('[AUTH] Invalid password')
return null
}
console.log('[AUTH] Successful login', user.email)
return {
id: user.id,
email: user.email,
name: user.name,
role: user.role,
username: user.username!,
}
},
}),
@@ -58,6 +53,7 @@ export const authOptions: NextAuthOptions = {
if (user) {
token.id = user.id
token.role = user.role
token.username = user.username
}
return token
},
@@ -65,6 +61,7 @@ export const authOptions: NextAuthOptions = {
if (session.user) {
session.user.id = token.id as string
session.user.role = token.role as "COUPLE" | "PLANNER" | "GUEST"
session.user.username = token.username as string
}
return session
},