added 2FA
This commit is contained in:
23
data/user.ts
23
data/user.ts
@@ -1,10 +1,14 @@
|
||||
'use server'
|
||||
|
||||
import { User } from '@prisma/client'
|
||||
import db from '@/lib/db'
|
||||
import journal from '@/actions/logger'
|
||||
|
||||
export const getUserByEmail = async (email: string): Promise<User | null> => {
|
||||
try {
|
||||
return await db.user.findUnique({ where: { email } })
|
||||
} catch {
|
||||
} catch (err) {
|
||||
journal.error({ getUserByEmail: err, email })
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -12,7 +16,22 @@ export const getUserByEmail = async (email: string): Promise<User | null> => {
|
||||
export const getUserById = async (id: string): Promise<User | null> => {
|
||||
try {
|
||||
return await db.user.findUnique({ where: { id } })
|
||||
} catch {
|
||||
} catch (err) {
|
||||
journal.error({ getUserById: err, id })
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const updateUserEmailVerified = async (id: string, email: string) => {
|
||||
try {
|
||||
await db.user.update({
|
||||
where: { id },
|
||||
data: {
|
||||
email, emailVerified: new Date(),
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
journal.error({ updateUserEmailVerified: err, id, email })
|
||||
return { error: 'db.error.update.user_data' }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user