jaynil_71939
11/28/2023, 2:44 PMrp_st
11/28/2023, 2:55 PMrp_st
11/28/2023, 2:55 PMjaynil_71939
11/28/2023, 4:03 PMrp_st
11/28/2023, 4:04 PMrp_st
11/28/2023, 4:05 PMjaynil_71939
11/28/2023, 4:07 PMrp_st
11/28/2023, 4:08 PMrp_st
11/28/2023, 4:08 PMcalum7865
11/28/2023, 4:19 PMrp_st
11/28/2023, 4:19 PMrp_st
11/28/2023, 4:19 PMrp_st
11/28/2023, 4:19 PMcalum7865
11/28/2023, 4:20 PMrp_st
11/28/2023, 4:20 PMrp_st
11/28/2023, 4:20 PMrp_st
11/28/2023, 4:21 PMcalum7865
11/28/2023, 4:23 PMcalum7865
11/28/2023, 4:24 PMrp_st
11/28/2023, 4:25 PMrp_st
11/28/2023, 4:25 PMcalum7865
11/28/2023, 4:26 PMrp_st
11/28/2023, 4:26 PMrp_st
11/28/2023, 4:26 PMcalum7865
11/28/2023, 4:27 PMcalum7865
11/28/2023, 4:27 PMdef setup(app: Flask):
if settings.TESTING:
return
init(
app_info=InputAppInfo(
app_name="PROSPECT 100",
api_domain=settings.auth.API_DOMAIN,
website_domain=settings.auth.WEBSITE_DOMAIN,
api_base_path="/api/v1/auth",
website_base_path="/auth"
),
supertokens_config=SupertokensConfig(
connection_uri=settings.supertokens.CONNECTION_URI,
api_key=settings.supertokens.API_KEY,
),
framework='flask',
recipe_list=[
session.init(),
dashboard.init(settings.supertokens.DASHBOARD_KEY),
thirdpartypasswordless.init(
flow_type="USER_INPUT_CODE",
contact_config=thirdpartypasswordless.ContactEmailOnlyConfig(),
providers=[
thirdpartypasswordless.Google(
client_id=settings.supertokens.GOOGLE_CLIENT_ID,
client_secret=settings.supertokens.GOOGLE_CLIENT_SECRET
)
],
email_delivery=EmailDeliveryConfig(override=partial(
email_delivery_override,
template=Email.AUTH_PASSWORDLESS_OTP,
context_fn=lambda x: {"otp": x.user_input_code}
)),
),
]
)
Middleware(app)
# This is required since if this is not there, then OPTIONS requests for
# the APIs exposed by the supertokens' Middleware will return a 404
@app.route('/', defaults={'u_path': ''})
@app.route('/<path:u_path>')
def catch_all(u_path: str):
abort(404)
rp_st
11/28/2023, 4:28 PMcalum7865
11/28/2023, 4:28 PMcalum7865
11/28/2023, 4:28 PMrp_st
11/28/2023, 4:29 PMcalum7865
11/28/2023, 4:30 PMrp_st
11/28/2023, 4:30 PMcalum7865
11/28/2023, 4:30 PMrp_st
11/28/2023, 4:31 PMcalum7865
11/28/2023, 4:33 PMrp_st
11/28/2023, 4:35 PMrp_st
11/28/2023, 4:36 PMcalum7865
11/28/2023, 4:38 PMrp_st
11/28/2023, 4:38 PMrp_st
11/28/2023, 4:39 PMcalum7865
11/28/2023, 4:39 PMcalum7865
11/28/2023, 4:40 PMrp_st
11/28/2023, 4:40 PMrp_st
11/28/2023, 4:41 PMcalum7865
11/28/2023, 4:43 PMrp_st
11/28/2023, 4:44 PMrp_st
11/28/2023, 4:44 PMrp_st
11/28/2023, 4:45 PMcalum7865
11/28/2023, 5:00 PM<SignInAndUp />
Component within our <AuthModal />
Component, this is inside of a global context so that we can open and close the auth modal from anywhere in the website. This is the auth modal code:
export default function AuthModal({
onHide,
show = false,
onboarding = false
}) {
return (
<Modal
show={show}
onHide={onHide}
centered
contentClassName='shadow-lg rounded-4'
data-testid='auth-modal'
backdrop={onboarding ? 'static' : true}
>
{(!onboarding) ? (
<SignInAndUp />
) : (
<UserOnboarding />
)}
</Modal>
);
}
and this is the context code:
return (
<AuthContext.Provider value={{ showAuth, hideAuth }}>
{children}
<AuthModal show={auth.show} onHide={hideAuth} {...auth.options} />
</AuthContext.Provider>
);
which is embedded within our App.js:
<UserContext.Provider value={{ user: userContext, setUser: (val) => { setUserContext({ ...val, doesSessionExist: sessionContext.doesSessionExist }) } }}>
<ConfigContext.Provider value={{ config: configContext, setConfig: (config) => { setConfigContext(config) } }}>
<GlobalAuth>
<RouterProvider router={router} />
</GlobalAuth>
</ConfigContext.Provider>
</UserContext.Provider>
We are also adding the supertokens auth routes into a react router dictionary so that you can hit the signinandup page through /Auth. We have a custom route which renders the modal embedded in the page to do this:
const router = Sentry.createBrowserRouter([
...createRoutes(routes),
...SuperTokens.getSuperTokensRoutes()
], {
future: {
v7_normalizeFormMethod: true
}
});
calum7865
11/28/2023, 5:00 PMexport const routes = {
auth: {
path: '/auth',
element: <AuthModal show />
},
....
}
rp_st
11/28/2023, 5:01 PMrp_st
11/28/2023, 5:01 PMSuperTokens.getSuperTokensRoutes()
rp_st
11/28/2023, 5:01 PMrp_st
11/28/2023, 5:02 PMSentry.createBrowserRouter
- maybe thats doing something that's causing remount for the screens created by SuperTokens.getSuperTokensRoutes()
(the callback screen is one of them)rp_st
11/28/2023, 5:03 PMrouter
is getting remounted as well?calum7865
11/28/2023, 5:09 PMrouter
to remount, unless it is Sentry? Is there anything we can do in the meantime to handle the request being sent twice in quick succession?rp_st
11/28/2023, 5:10 PMrp_st
11/28/2023, 5:11 PMrp_st
11/28/2023, 6:04 PMcalum7865
11/28/2023, 6:04 PMrp_st
11/28/2023, 6:04 PMrp_st
11/28/2023, 6:05 PMcalum7865
11/28/2023, 6:05 PMcalum7865
11/28/2023, 6:05 PMrp_st
11/28/2023, 6:06 PMbarnz0793
12/01/2023, 2:44 PMrp_st
12/01/2023, 2:50 PMlucasf4703
01/09/2024, 5:36 AM<Provider instance={rollbarConfiguredInstance}>
<ErrorBoundary>{children}</ErrorBoundary>
</Provider>
causing a remount and the double /auth/signinup