hundreds-psychiatrist-38730
04/12/2025, 11:32 AMsdk
.updateLoginFlow({ flow: flow.id, updateLoginFlowBody: body })
.then((data) => {
console.log('successfull login')
console.log('data', data.session)
setSession(data.session)
profileData(data.session)
if (flow?.return_to) {
window.location.href = flow?.return_to
return
}
toast({ description: 'Signed In Successfully!' })
router.push('/dashboard/overview')
}).catch(foo)
I have added profileData()
to request my own backend for stuff.
what would you do to cancel login and throw e.g. a toast
if profileData()
fails ?bland-eye-99092
04/12/2025, 4:42 PMhundreds-psychiatrist-38730
04/12/2025, 5:20 PMcreateBrowserLogoutFlow
first.bland-eye-99092
04/12/2025, 6:49 PMcreateBrowserLogoutFlow
and updateLogoutFlow
immediately after another.
I just think in general, it's probably a good idea to decouple the steps a little bit - don't really have a specific example, because this depends a lot on your architecture.hundreds-psychiatrist-38730
04/12/2025, 7:35 PMprofileData
is this simple one.
const profileData = (session: Session) => {
fetch('<http://localhost:8080/users/>' + session.identity?.id, { mode: 'cors' })
.then((res) => {
if (!res.ok) {
throw new Error(`HTTP error, status = ${res.status}`)
}
return res.json()
})
.then((data) => setProfile({
profile_picture: data.data.ProfilePicture,
city: data.data.City,
country: data.data.Country,
zipcode: data.data.Zipcode,
use_gravatar: data.data.UseGravatar
}))
}
so any rough setup of the decoupling i imagine i need to move setSession()
and my profileData()
+ the router.push()
out of the then()
of updateLoginFlow()