added 2FA
This commit is contained in:
33
data/two-factor-confirmation.ts
Normal file
33
data/two-factor-confirmation.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
'use server'
|
||||
|
||||
import db from '@/lib/db'
|
||||
import journal from '@/actions/logger'
|
||||
|
||||
export const createTwoFactoComfirmation = async (userId: string) => {
|
||||
try {
|
||||
return await db.twoFactorComfirmation.create({ data: { userId } })
|
||||
} catch (err) {
|
||||
journal.error({ createTwoFactoComfirmation: err, userId })
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const getTwoFactorConfirmationByUserId = async (userId: string) => {
|
||||
try {
|
||||
return await db.twoFactorComfirmation.findUnique({
|
||||
where: { userId },
|
||||
})
|
||||
} catch (err) {
|
||||
journal.error({ getTwoFactorConfirmationByUserId: err, userId })
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const deleteTwoFactoComfirmation = async (id: string) => {
|
||||
try {
|
||||
return await db.twoFactorComfirmation.delete({ where: { id } })
|
||||
} catch (err) {
|
||||
journal.error({ deleteTwoFactoComfirmation: err, id })
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user