hundreds-psychiatrist-38730
08/21/2024, 6:46 PMupdateLoginFlow()
in the TS/JS sdk.
does that technically do .toSession()
behind the scenes ?? i don't feel like it does.
sdk
.updateLoginFlow({ flow: flow.id, updateLoginFlowBody: body })
.then(() => {
// we successfully submitted the login flow, so lets redirect to the dashboard
navigate({ to: "/dashboard", replace: true })
})
.catch(sdkErrorHandler)
}
simply because the dashboard.tsx
example has this written:
useEffect(() => {
// we check if the user is logged in by checking if there is a session
// if no session is found, we redirect to the login page
sdk
.toSession()
.then(({ data: session }) => {
// we set the session data which contains the user Identifier and other traits.
setSession(session)
// Set logout flow
createLogoutFlow()
})
.catch(sdkErrorHandler)
.catch((error) => {
// Handle all other errors like error.message "network error" if Kratos can not be connected etc.
if (error.message) {
return navigate(`/error?error=${encodeURIComponent(error.message)}`, {
replace: true,
})
}
// Just stringify error and print all data
navigate(`/error?error=${encodeURIComponent(JSON.stringify(error))}`, {
replace: true,
})
})
}
so here's how i understand it works.
When being redirected to /dashboard
after my creds are correct, then the navigate returns back the session_token
to dashboard
and the useEffect()
code runs before the page is loaded, and do the .toSession()
that then trigger setSession()
etc..
is that correctly understood?bland-eye-99092
08/21/2024, 7:28 PM