want to redirectTo=customURL after login
trying to log a desktop client. desktop client sends /login?authKey=XXX i want to write logic that if authkey is present redirectTo /loginSuccess if not default behaviour. I didn't find a hook for this, wondering if you have any ideas?
3 Replies
Hi @devrim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In Wasp, you can specify where to redirect after a successful login/signup using the
onAuthSucceededRedirectTo
field in your auth
configuration. The default value is "/", but you can set it to any route you want. Here is an example of how to use it:
However, this will redirect all successful logins to the specified route. If you want to conditionally redirect based on the presence of an authKey
, you might need to implement custom logic.
Currently, Wasp does not support hooks after login/sign-in to execute custom server code, but it is a feature that is planned for a future release. In the meantime, you can implement your own Auth UI component and your own signup/login actions to handle custom logic. You can find more information on how to do this in the Wasp documentation (https://wasp-lang.dev/docs/auth/username-and-pass#2-creating-your-custom-sign-up-action).
Please note that the custom logic you implement would need to handle the extraction and verification of the authKey
from the URL, and then perform the appropriate redirect.
Sources:
- Wasp Auth Overview (https://wasp-lang.dev/docs/auth/overview#onauthsucceededredirectto-string)
- Github Issue: Add hooks after login / sign-in (https://github.com/wasp-lang/wasp/issues/1556)
- Discord Support Thread (https://discord.com/channels/686873244791210014/1217452914503585902)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @devrim, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Hey @devrim.
Hmm, I have to admit I don't know how to do this in Wasp. @miho Can he use the
req
argument in the onAfterLogin
hook?We currently don't support custom redirect logic after login buuuut it's quite easy to have the redirect be
/something
and then on that page you have some logic that redirects to a different page based on some checks.