Started introducing prisma to connect to MongoDB
This commit is contained in:
parent
8397320a6b
commit
530a58f703
11 changed files with 1734 additions and 42 deletions
19
leaky-ships/lib/backend/jwtVerifyCatch.ts
Normal file
19
leaky-ships/lib/backend/jwtVerifyCatch.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
export default async function jwtVerifyCatch(
|
||||
tokenType: 'refreshToken' | 'accessToken',
|
||||
err: Error
|
||||
) {
|
||||
switch (err.message) {
|
||||
case 'jwt expired':
|
||||
return { message: `JWT (${tokenType}) expired!`, statusCode: 403, solved: true, type: 'warn' }
|
||||
|
||||
case 'invalid signature':
|
||||
return { message: `Invalid JWT (${tokenType}) signature! Token: `, statusCode: 401, solved: true, type: 'error' }
|
||||
|
||||
case 'jwt must be provided':
|
||||
return { message: `No JWT (${tokenType}) given.`, statusCode: 401, solved: true, type: 'warn' }
|
||||
|
||||
default:
|
||||
console.log(err)
|
||||
return { message: `Unknown error on 'JWT.verify()'.`, solved: false }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue