significant refactor
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import SuperTokens from 'supertokens-web-js';
|
||||
import Session from 'supertokens-web-js/recipe/session';
|
||||
import Passwordless from 'supertokens-web-js/recipe/passwordless';
|
||||
import { appInfo } from './config';
|
||||
import { logger } from './';
|
||||
import SuperTokens from "supertokens-web-js";
|
||||
import Session from "supertokens-web-js/recipe/session";
|
||||
import Passwordless from "supertokens-web-js/recipe/passwordless";
|
||||
import { appInfo } from "./config";
|
||||
import { logger } from "./";
|
||||
|
||||
export const frontendConfig = () => {
|
||||
return {
|
||||
@@ -12,27 +12,27 @@ export const frontendConfig = () => {
|
||||
Session.init({
|
||||
tokenTransferMethod: "cookie",
|
||||
sessionTokenBackendDomain: undefined,
|
||||
|
||||
|
||||
preAPIHook: async (context) => {
|
||||
context.requestInit.credentials = "include";
|
||||
return context;
|
||||
},
|
||||
})
|
||||
]
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let initialized = false;
|
||||
export function ensureSuperTokensFrontend() {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
if (!initialized) {
|
||||
SuperTokens.init(frontendConfig());
|
||||
initialized = true;
|
||||
logger.info("Initialized");
|
||||
|
||||
Session.doesSessionExist().then(exists => {
|
||||
logger.info(`Session does${exists ? '' : 'NOT'} exist on load!`);
|
||||
|
||||
Session.doesSessionExist().then((exists) => {
|
||||
logger.info(`Session does${exists ? "" : "NOT"} exist on load!`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user