custom auth ui
If I create a custom ui for the authentication portion of wasp and using the hooks from wasp, do these methods defined in the main.wasp file still function? Or do I need to handle redirects on my own?
onAuthFailedRedirectTo: "/login",
onAuthSucceededRedirectTo: "/demo-app",
4 Replies
Wohooo @hadanator, you just became a Waspeteer level 4!
Hi @hadanator. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
If you create a custom authentication UI in Wasp and use the authentication hooks (such as the login and signup actions), the behavior of the redirect fields in your
-
main.wasp
file depends on which part of the authentication flow you are customizing.
- onAuthFailedRedirectTo: This field controls where unauthenticated users are redirected when they try to access a page with authRequired: true
. This redirect is handled by Wasp itself, not by the Auth UI, so it will still function as expected even if you use a custom Auth UI. Unauthenticated users will be redirected to the route you specify (e.g., /login
) when they try to access protected pages Protecting a page with authRequired.
- onAuthSucceededRedirectTo: This field controls where users are redirected after a successful login or signup. However, the automatic redirect on successful login/signup only works when you use the Wasp-provided Auth UI. If you implement your own custom Auth UI, you will need to handle the redirect yourself after a successful authentication onAuthSucceededRedirectTo: String.
Summary:-
onAuthFailedRedirectTo
will still work with a custom Auth UI.
- onAuthSucceededRedirectTo
will not work automatically with a custom Auth UI; you must handle the redirect in your custom code.
Let me know if you need guidance on how to implement redirects in your custom UI!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @hadanator, 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?All good, @hadanator ?
Let us know if oyu have more questions.
Yup all good on this one. The ai was very helpful for this question.