Improve error handling on cookie parsing, closes #4246
This commit is contained in:
@@ -16,9 +16,13 @@ import { User, Event, Team, Collection, View } from "@server/models";
|
|||||||
* @returns The session details
|
* @returns The session details
|
||||||
*/
|
*/
|
||||||
export function getSessionsInCookie(ctx: Context) {
|
export function getSessionsInCookie(ctx: Context) {
|
||||||
return JSON.parse(
|
try {
|
||||||
decodeURIComponent(ctx.cookies.get("sessions") || "") || "{}"
|
const sessionCookie = ctx.cookies.get("sessions") || "";
|
||||||
);
|
const decodedSessionCookie = decodeURIComponent(sessionCookie);
|
||||||
|
return decodedSessionCookie ? JSON.parse(decodedSessionCookie) : {};
|
||||||
|
} catch (err) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function signIn(
|
export async function signIn(
|
||||||
|
|||||||
Reference in New Issue
Block a user