How to integrate Django API Sign Up with Wasp
I have a standalone Django Rest API that has its own Sign Up and Login process and all that. I'm trying to make it so that when a new user is created in wasp and added to the prisma database, a post request is made to my Django API's User Create endpoint, so that I can create a user there as well. This will let me make authenticated requests to the API for other endpoints and purposes.
However, I can't figure out how and where to add my code for the Django request. I could potentially modify the wasp LoginandSignupForm itself, but I'd rather not modify that code.
If I were to just create an action to make this request, how would I incorporate that into the signup page, since the Signup Form component can't be modified directly in the SignupPage.tsx.
I'm just completely lost on this and have spent around 8 hours trying to figure this out. If anyone has any suggestions that would be really helpful.
11 Replies
Hey, sorry to hear you had a hard time with this! To add functionality into your auth flow, you need to create a custom sign-up action: https://wasp-lang.dev/docs/auth/username-and-pass#2-creating-your-custom-sign-up-action
This means you won't be able to use Auth UI forms, but you can copy/paste their code to create the component yourself
Username & Password | Wasp
Wasp supports username & password authentication out of the box with login and signup flows. It provides you with the server-side implementation and the UI components for the client-side.
what auth methods are you using?
I'm using google and username and password
got it. not sure if there is an equivalent of this custom signup action for google, @miho is the person to help with this
Should I DM him?
I tagged him here, so he will answer as soon as he is online! It's 10pm in his timezone atm
Cool thanks, I'll try to do it for username and password for now
Wohooo @rithvik12345678, you just became a Waspeteer level 1!
We don't currently have
onLogin
and onSignup
hooks. It's on our radar and we'll work on it in the future. https://github.com/wasp-lang/wasp/issues/1556
Right now, there isn't a way to run some code on signup or on login.
One alternative way you can solve the problem is to have a custom job that runs each minute and checks the list of users in your Wasp DB and call the Python API: https://wasp-lang.dev/docs/advanced/jobsGitHub
Add hooks after login / sign-in, to execute custom server code · Is...
Be able to execute custom server actions after a successful auth Both after signup and login would be best case scenario. I would like to redirect user to a 'setup workspace' flow after reg...
Recurring Jobs | Wasp
In most web apps, users send requests to the server and receive responses with some data. When the server responds quickly, the app feels responsive and smooth.
@miho So I'd basically be running the job to periodically check for a new user and then make a django post request everytime there's a new user profile in the DB. The only issue with the this is the timing might be off, but I could likely do it every second.
The lowest resolution is 1 minute for our jobs unfortunately (we are using PgBoss for jobs scheduling) 😄 Would that work for you?