1
0
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:
Yury Shkoda
2022-06-21 18:28:13 +03:00
parent a4d5ee99c4
commit bcef9a4a9d
13 changed files with 322 additions and 6 deletions

View File

@@ -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,