delete api and will start over for it

This commit is contained in:
talksik
2022-06-02 12:03:28 -05:00
parent bdbd65972a
commit e466e99b36
18 changed files with 0 additions and 1322 deletions
-39
View File
@@ -1,39 +0,0 @@
import { NextFunction, Request, Response } from "express";
import { loadConfig } from "../config";
const jwt = require("jsonwebtoken");
const config = loadConfig();
// used by specific routes that need to authentication
export const authCheck = async (
req: Request,
res: Response,
next: NextFunction
) => {
try {
const { authorization } = req.headers;
if (!authorization) {
throw Error("No provided header");
}
// verify jwt token with our api secret
var decoded: JwtClaims = jwt.verify(authorization, config.JWT_TOKEN_SECRET);
res.locals.userInfo = decoded;
next();
} catch (error) {
res.status(401).send("unauthorized");
}
};
export interface JwtClaims {
userId: string;
googleUserId: string;
picture: string;
email: string;
name: string;
}