add verify token
This commit is contained in:
parent
dba761dcb1
commit
8c6c60964b
23
src/pages/api/verify.ts
Normal file
23
src/pages/api/verify.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import {NextApiRequest, NextApiResponse} from 'next'
|
||||
import { prisma } from '~/server/db'
|
||||
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const {token } = req.body
|
||||
|
||||
if(!token) {
|
||||
return res.status(400).json({error: 'Token is required'})
|
||||
}
|
||||
|
||||
const isUserExist = await prisma.user.findFirst({
|
||||
where: {
|
||||
access_token: token
|
||||
}
|
||||
})
|
||||
|
||||
if(!isUserExist) {
|
||||
return res.status(400).json({error: 'Invalid token'})
|
||||
}
|
||||
|
||||
return res.status(200).json({message: 'Token is valid'})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user