mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Handle website delete. Added response helper functions.
This commit is contained in:
parent
0a411a9ad6
commit
c4b75e4aec
31 changed files with 314 additions and 96 deletions
|
|
@ -17,19 +17,23 @@ export function use(middleware) {
|
|||
export const useCors = use(cors());
|
||||
|
||||
export const useSession = use(async (req, res, next) => {
|
||||
try {
|
||||
req.session = await verifySession(req);
|
||||
} catch {
|
||||
const session = await verifySession(req);
|
||||
|
||||
if (!session) {
|
||||
return res.status(400).end();
|
||||
}
|
||||
|
||||
req.session = session;
|
||||
next();
|
||||
});
|
||||
|
||||
export const useAuth = use(async (req, res, next) => {
|
||||
try {
|
||||
req.auth = await verifyAuthToken(req);
|
||||
} catch {
|
||||
const token = await verifyAuthToken(req);
|
||||
|
||||
if (!token) {
|
||||
return res.status(401).end();
|
||||
}
|
||||
|
||||
req.auth = token;
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue