Add independent administrative authentication foundation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../../middleware/apiResponse";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "GET");
|
||||
|
||||
if (req.method !== "GET") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const token = readAdminSessionCookie(req);
|
||||
return respondSuccess(res, {
|
||||
authenticated: validateAdminSession(token)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user