mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Fix crash on invalid data.
This commit is contained in:
parent
ebad20ce0e
commit
1aa9689b4f
@ -18,9 +18,13 @@ export function use(middleware) {
|
|||||||
export const useCors = use(cors());
|
export const useCors = use(cors());
|
||||||
|
|
||||||
export const useSession = use(async (req, res, next) => {
|
export const useSession = use(async (req, res, next) => {
|
||||||
const session = await verifySession(req).catch(e => {
|
let session;
|
||||||
|
|
||||||
|
try {
|
||||||
|
session = await verifySession(req);
|
||||||
|
} catch (e) {
|
||||||
return serverError(res, e.message);
|
return serverError(res, e.message);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
@ -31,9 +35,13 @@ export const useSession = use(async (req, res, next) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const useAuth = use(async (req, res, next) => {
|
export const useAuth = use(async (req, res, next) => {
|
||||||
const token = await verifyAuthToken(req).catch(e => {
|
let token;
|
||||||
|
|
||||||
|
try {
|
||||||
|
token = await verifyAuthToken(req);
|
||||||
|
} catch (e) {
|
||||||
return serverError(res, e.message);
|
return serverError(res, e.message);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return unauthorized(res);
|
return unauthorized(res);
|
||||||
|
Loading…
Reference in New Issue
Block a user