mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
throw errors instead of returning them, define interface for jwt payload
This commit is contained in:
parent
96def721ff
commit
4ab08460a3
@ -20,5 +20,5 @@ export const isAuthorized: AuthChecker<any> = async ({ root, args, context, info
|
||||
return result.success
|
||||
}
|
||||
}
|
||||
return false
|
||||
throw new Error('401 Unauthorized')
|
||||
}
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import jwt, { JwtPayload } from 'jsonwebtoken'
|
||||
import CONFIG from '../config/'
|
||||
|
||||
@ -9,8 +6,14 @@ interface CustomJwtPayload extends JwtPayload {
|
||||
pubKey: Buffer
|
||||
}
|
||||
|
||||
export default (token: string): any => {
|
||||
if (!token) return new Error('401 Unauthorized')
|
||||
type DecodedJwt = {
|
||||
token: string
|
||||
sessionId: number
|
||||
pubKey: Buffer
|
||||
}
|
||||
|
||||
export default (token: string): DecodedJwt => {
|
||||
if (!token) throw new Error('401 Unauthorized')
|
||||
let sessionId = null
|
||||
let pubKey = null
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user