Lucifer979
drixhua
Tushar
aquamarine2620
console.log('toto1') const session = await Session.getSession(req, res) const user = await EmailPassword.getUserById(session.getUserId()) console.log('toto2') if (user === undefined) { next(new Error('INTERNAL_AUTHENTICATION_ERROR')) return } const { metadata } = await UserMetadata.getUserMetadata(user.id)
recipeList: [ UserRoles.init(), // RBAC Session.init({ cookieDomain: `.${process.env.CLUSTER_HOST ?? ''}` }), // initializes session features UserMetadata.init() ]
/app/node_modules/supertokens-node/lib/build/recipe/emailpassword/recipe.js:204 throw new Error("Initialisation not done. Did you forget to call the SuperTokens.init function?"); ^ Error: Initialisation not done. Did you forget to call the SuperTokens.init function? at Recipe.getInstanceOrThrowError (/app/node_modules/supertokens-node/lib/build/recipe/emailpassword/recipe.js:204:15) at Object.getUserById (/app/node_modules/supertokens-node/lib/build/recipe/emailpassword/index.js:72:33) at file:///app/dist/endpoints/save_shipping/post/controller.js:18:38 at Generator.next (<anonymous>) at fulfilled (file:///app/dist/endpoints/save_shipping/post/controller.js:4:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
hfakar
trivialkettle
kiesker
import { SuperTokensConfig, PreBuiltUIList } from './database/auth/supertoken'; import SuperTokens, { SuperTokensWrapper } from "supertokens-auth-react"; import { Routes, BrowserRouter as Router, Route } from "react-router-dom"; import { getSuperTokensRoutesForReactRouterDom } from 'supertokens-auth-react/ui' import { SessionAuth, SessionContext } from "supertokens-auth-react/recipe/session" //Components import Navbar from './components/nav/Navbar'; import NavbarAuth from './components/nav/NavbarAuth'; //Free Routes import Home from './routes/free/Home'; //Protected User Routes import Profile from './routes/user/Profile'; //Protecte Admin Routes SuperTokens.init(SuperTokensConfig); function App() { //Here const check = SessionContext; return ( <SuperTokensWrapper> <div className='App app-container'> <Router> {check ? <Navbar /> : <NavbarAuth />} <Routes> {/* This shows the login UI on "/auth" route */} {getSuperTokensRoutesForReactRouterDom(require("react-router-dom"), PreBuiltUIList)} {/* Unprotected route */} <Route path="/" element={<Home />} /> {/* Unprotected route */} {/* Protected route Users */} <Route path="/profile" element={ /* This protects the "/" route so that it shows <Home /> only if the user is logged in. Else it redirects the user to "/auth" */ <SessionAuth> <Profile /> </SessionAuth> } /> {/* Protected route Users */} </Routes> </Router> </div> </SuperTokensWrapper> ); } export default App;
Erick
mukulg22
Kranos
await Session.getUserId()
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).