added 2FA

This commit is contained in:
2024-04-26 22:16:21 +03:00
parent 53cadc289a
commit f17a002ac6
38 changed files with 1036 additions and 414 deletions

33
data/two-factor-token.ts Normal file
View File

@@ -0,0 +1,33 @@
'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
}
}