v1.8.0 #429
@@ -239,12 +239,19 @@ class AuthManager {
|
|||||||
|
|
||||||
createAdminMiddleware() {
|
createAdminMiddleware() {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const authHeader = req.headers["authorization"];
|
let token = req.cookies?.jwt;
|
||||||
if (!authHeader?.startsWith("Bearer ")) {
|
|
||||||
return res.status(401).json({ error: "Missing Authorization header" });
|
if (!token) {
|
||||||
|
const authHeader = req.headers["authorization"];
|
||||||
|
if (authHeader?.startsWith("Bearer ")) {
|
||||||
|
token = authHeader.split(" ")[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return res.status(401).json({ error: "Missing authentication token" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = authHeader.split(" ")[1];
|
|
||||||
const payload = await this.verifyJWTToken(token);
|
const payload = await this.verifyJWTToken(token);
|
||||||
|
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
|
|||||||
Reference in New Issue
Block a user