better logging
This commit is contained in:
parent
64a750cac0
commit
159f4cc2ca
|
@ -4,13 +4,15 @@ const isProduction = process.env.NODE_ENV === "production";
|
|||
|
||||
export default function authServerSideProps(getServerSideProps) {
|
||||
return function authenticate(context) {
|
||||
if (isProduction && (!("ory_kratos_session" in context.req.cookies) || !("skynet-jwt" in context.req.cookies))) {
|
||||
if ("skynet-jwt" in context.req.cookies) {
|
||||
console.log(`Cookie skynet-jwt is present but ory_kratos_session is not - redirecting to login`);
|
||||
}
|
||||
const authCookies = ["ory_kratos_session", "skynet-jwt"];
|
||||
|
||||
if ("ory_kratos_session" in context.req.cookies) {
|
||||
console.log(`Cookie ory_kratos_session is present but skynet-jwt is not - redirecting to login`);
|
||||
if (isProduction && !authCookies.every((cookie) => context.req.cookies[cookie])) {
|
||||
// it is higly unusual that some of the cookies would be set but other would not
|
||||
if (authCookies.some((cookie) => context.req.cookies[cookie])) {
|
||||
console.log(
|
||||
"Unexpected auth cookies state!",
|
||||
authCookies.map((cookie) => `[${cookie}] is ${context.req.cookies[cookie] ? "set" : "not set"}`)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Reference in New Issue