improve error handling
This commit is contained in:
parent
e1ec65350d
commit
bcfba8b448
5 changed files with 22 additions and 20 deletions
|
@ -6,10 +6,10 @@ import InternalException from "../exceptions/internalException";
|
|||
import { JWTHelper } from "../helpers/jwtHelper";
|
||||
|
||||
export default async function authenticate(req: Request, res: Response, next: Function) {
|
||||
const bearer = req.headers.authorization;
|
||||
const bearer = req.headers.authorization?.split(" ")?.[1] ?? undefined;
|
||||
|
||||
if (!bearer) {
|
||||
throw new BadRequestException("Provide Authorization Header");
|
||||
throw new BadRequestException("Provide valid Authorization Header");
|
||||
}
|
||||
|
||||
let decoded: string | jwt.JwtPayload;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue