Hey, is there any workaround for 2fa to have redirect url? This seems like a blocker. If you want to...
o
Hey, is there any workaround for 2fa to have redirect url? This seems like a blocker. If you want to redirect users to different apps after login, how can you achieve that?
r
hey @ovidije when you say different apps, do you mean different sub domains or entirely different domains? Or just different paths?
o
Different paths and different subdomains
r
right. So you could redirect the user to some path which you control (on success), and then on that path, you can have your own logic to further redirect the user to their sub domain
o
Imagine following example: - we have a multi tenant application and you can invite users to apps - user gets invite with link: domain.com/tenant/invite - user gets redirected to login after accepting invite - users logs in - how to redirect user back to (eg.) domain.com/tenant/invite/onboarding - we have two apps, for clients and admins (same user pool) - user gets redirected from "app1.domain.com" to identity.domain.com in order to login - user logs in - user gets redirected back to app1.domain.com after login - same flow applies for app2.domain.com How could I achieve this if I have 2fa in place (email+password + passwordless) recipe?
r
right. So post login of passwordless, you can redirect the user to some path like
/redirect
. On that path, you check if a session exists and what kind of a user it is (admin or not), based on which you can further rediect them to their sub domain
o
Hm, but logic is really dependant on the domin from which user is coming. eg. User can be both (admin + client) eg. User can have multiple invites to multiple tenants at the same time One option would be for me to store when user is accessing domain in cookie and check that cookie on redirect page? Is there maybe a way to pass this info and store it in sessions somehow?
ps. I'm not a FE guy, so I have limited technical knowledge on how FE would do this.
r
yea you can pass that info into the session: - use our pre API hook to add the info to the request body during sign in (first factor) - access the request object from the userContext obj in the createNewSession override on the backend to read from that and modify the access token paylaod.
o
Thanks @rp_st , I'll have to give it a try and see how this will work.
I managed to pass the data and add it into payload. I have one more question, can I access session payload in: getRedirectionURL on frontend
r
yea. Using the session recipe
Session.getAccessTokenPayloadSecurely()
o
Thanks a lot!
5 Views