mirror of
https://github.com/sasjs/server.git
synced 2026-01-12 00:30:06 +00:00
chore: wip replicating folders api
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { Request, Response } from 'express'
|
||||
import { verifyTokenInDB } from '../utils'
|
||||
import { headerIsNotPresentMessage, headerIsNotValidMessage } from './header'
|
||||
|
||||
export const authenticateAccessToken = (req: any, res: any, next: any) => {
|
||||
authenticateToken(
|
||||
@@ -21,6 +23,18 @@ export const authenticateRefreshToken = (req: any, res: any, next: any) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const verifyAuthHeaderIsPresent = (req: Request, res: Response) => {
|
||||
console.log(`🤖[verifyAuthHeaderIsPresent]🤖`)
|
||||
|
||||
const authHeader = req.headers.authorization
|
||||
|
||||
if (!authHeader) {
|
||||
return res.status(401).json(headerIsNotPresentMessage('Authorization'))
|
||||
} else if (!/^Bearer\s.{1}/.test(authHeader)) {
|
||||
return res.status(401).json(headerIsNotValidMessage('Authorization'))
|
||||
}
|
||||
}
|
||||
|
||||
const authenticateToken = (
|
||||
req: any,
|
||||
res: any,
|
||||
|
||||
Reference in New Issue
Block a user