W
Wasp•10mo ago
rithvik12345678

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.
import { SignupForm } from 'wasp/client/auth';
import { Link } from 'react-router-dom';
import { AuthWrapper } from './authWrapper';

export function Signup() {
return (
<AuthWrapper>
<SignupForm />
<br />
<span className='text-sm font-medium text-gray-900'>
I already have an account (
<Link to='/login' className='underline'>
go to login
</Link>
).
</span>
<br />
</AuthWrapper>
);
}
import { SignupForm } from 'wasp/client/auth';
import { Link } from 'react-router-dom';
import { AuthWrapper } from './authWrapper';

export function Signup() {
return (
<AuthWrapper>
<SignupForm />
<br />
<span className='text-sm font-medium text-gray-900'>
I already have an account (
<Link to='/login' className='underline'>
go to login
</Link>
).
</span>
<br />
</AuthWrapper>
);
}
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
matijash
matijash•10mo ago
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.
matijash
matijash•10mo ago
what auth methods are you using?
rithvik12345678
rithvik12345678OP•10mo ago
I'm using google and username and password
matijash
matijash•10mo ago
got it. not sure if there is an equivalent of this custom signup action for google, @miho is the person to help with this
rithvik12345678
rithvik12345678OP•10mo ago
Should I DM him?
matijash
matijash•10mo ago
I tagged him here, so he will answer as soon as he is online! It's 10pm in his timezone atm
rithvik12345678
rithvik12345678OP•10mo ago
Cool thanks, I'll try to do it for username and password for now
MEE6
MEE6•10mo ago
Wohooo @rithvik12345678, you just became a Waspeteer level 1!
miho
miho•10mo ago
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/jobs
GitHub
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.
rithvik12345678
rithvik12345678OP•10mo ago
@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.
miho
miho•10mo ago
The lowest resolution is 1 minute for our jobs unfortunately (we are using PgBoss for jobs scheduling) 😄 Would that work for you?
Want results from more Discord servers?
Add your server