mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 19:44:35 +00:00
fix: call jwt.verify in synchronous way
This commit is contained in:
@@ -93,10 +93,8 @@ const authenticateToken = async (
|
|||||||
try {
|
try {
|
||||||
if (!token) throw 'Unauthorized'
|
if (!token) throw 'Unauthorized'
|
||||||
|
|
||||||
jwt.verify(token, key, async (err: any, data: any) => {
|
const data: any = jwt.verify(token, key)
|
||||||
if (err) throw 'Unauthorized'
|
|
||||||
|
|
||||||
// verify this valid token's entry in DB
|
|
||||||
const user = await verifyTokenInDB(
|
const user = await verifyTokenInDB(
|
||||||
data?.userId,
|
data?.userId,
|
||||||
data?.clientId,
|
data?.clientId,
|
||||||
@@ -113,7 +111,6 @@ const authenticateToken = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw 'Unauthorized'
|
throw 'Unauthorized'
|
||||||
})
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (await isPublicRoute(req)) {
|
if (await isPublicRoute(req)) {
|
||||||
req.user = publicUser
|
req.user = publicUser
|
||||||
|
|||||||
Reference in New Issue
Block a user