33 lines
799 B
TypeScript
33 lines
799 B
TypeScript
'use server'
|
|
|
|
import db from '@/lib/db'
|
|
import journal from '@/actions/logger'
|
|
|
|
export const getTwoFactorTokenByToken = async (token: string) => {
|
|
try {
|
|
return await db.twoFactorToken.findUnique({
|
|
where: { token },
|
|
})
|
|
} catch (err) {
|
|
journal.error({ getTwoFactorTokenByToken: err, token })
|
|
return null
|
|
}
|
|
}
|
|
|
|
export const getTwoFactorTokenByEmail = async (email: string) => {
|
|
try {
|
|
return await db.twoFactorToken.findFirst({ where: { email } })
|
|
} catch (err) {
|
|
journal.error({ getTwoFactorTokenByEmail: err, email })
|
|
return null
|
|
}
|
|
}
|
|
|
|
export const deleteTwoFactorToken = async (id: string) => {
|
|
try {
|
|
return await db.twoFactorToken.delete({ where: { id } })
|
|
} catch (err) {
|
|
journal.error({ deleteTwoFactorToken: err, id })
|
|
return null
|
|
}
|
|
} |