https://supertokens.com/ logo
Showing sign up by default
c

Chronos

04/18/2023, 7:55 PM
Is there a way to show the "Sign Up" form by default instead of the "Sign In" page first when using ? Or is there an alternate just for SignUp?
r

rp

04/19/2023, 4:46 AM
c

Chronos

04/19/2023, 2:12 PM
Thanks that helped. The one thing I can't seem to get working is the redirect on signup, I've added code in multiple places and it seems like none are firing. I'm using NextJs. I'm not sure if using the override code shown to allow for extra fields on signup also overrides the redirect on success code shown elsewhere?
getRedirectionURL doesn't seem to trigger
r

rp

04/19/2023, 2:14 PM
Are you using our pre built UI for sign up, or calling the sign up function yourself? Also, can i see where you have provided the
getRedirectionURL
function?
c

Chronos

04/19/2023, 2:15 PM
Right now I'm using your pre-built UI for signup, let me grab a code slice here
here's part of my backendConfig: (need to break up for character limit)
EmailPasswordNode.init({ signUpFeature: { formFields: [{ id: "name" }, { id: "company", optional: true }] }, signInAndUpFeature: { defaultToSignUp: true },
getRedirectionURL: async (context) => { if (context.action === "RESET_PASSWORD") { // called when the user clicked on the forgot password button } else if (context.action === "SUCCESS") { // called on a successful sign in / up. Where should the user go next? console.log("Context.action is SUCCESS"); let redirectToPath = context.redirectToPath; console.log("redirectToPath is: " + redirectToPath); // if (redirectToPath !== undefined) { // // we are navigating back to where the user was before they authenticated // return redirectToPath; // } if (context.isNewUser) { // user signed up return "/onboarding" } else { // user signed in return "/dashboard" } } // return undefined to let the default behaviour play out return undefined; },
override: { apis: (originalImplementation) => { return { ...originalImplementation, signUpPOST: async function (input) { if (originalImplementation.signUpPOST === undefined) { throw Error("Should never come here"); } // First we call the original implementation of signUpPOST. let response = await originalImplementation.signUpPOST(input); // Post sign up response, we check if it was successful if (response.status === "OK") { // These are the input form fields values that the user used while signing up let formFields = input.formFields; // console.log("signup form fields:"); var name = formFields.find(i => i.id === "name").value; var userId = response.user.id; var returnObject = { didWork: false, error: "" }; //db calls hidden here } return response; } } } }
r

rp

04/19/2023, 2:21 PM
Wait... this is backend code?
The
getRedirectionURL
goes on the frontend
If you see the titles of the code snippets on the link above,
getRedirectionURL
is used under react, angular and vue code tabs
c

Chronos

04/19/2023, 2:26 PM
ohh, hmm, it wasn't obvious (or isn't in a lot of spots with code samples) if something is front end or back end. I guess React is really only rendering front end stuff, but it's easy to lose track. I feel like every code sample should have it specifically called out.
I'm building off of the NextJS sample, which has a frontendConfig and a backendConfig file, but they look very similar, so it's easy to mix up where something goes
r

rp

04/19/2023, 2:30 PM
I see. That's a fair point.
ANy ideas on how we can make it obvious? We had earlier tried to do it based on comments in the code, but people missed that too..
like a line at the top of the code:
// this is on the frontend
c

Chronos

04/19/2023, 2:32 PM

https://cdn.discordapp.com/attachments/1097973696695640265/1098254780582871090/example1.PNG

I was kind of expecting to see this above every code box
Just a big title saying front end or back end
Since I'm not as familiar with how SuperTokens works yet, what's in front vs back, and auth is something that is just confusing by default and makes your eyes and brain glaze over
even though I can step back and say, wait you are sending a response something works, of course I need to redirect on the front end based on the result, I don't think I can just send a response back with the URL I want and have it magically work, but then again I'm not 100% sure what is catching my code on the front and what it's doing, so...
There's definitely some good examples in your docs, but it can be unclear to figure out where some stuff goes if you aren't super familiar with it yet, and I know you guys would know it in-and-out and it may be harder to step back and see how the rest of us can struggle understanding how it's all put together
r

rp

04/19/2023, 2:36 PM
fair enough. We will note this feedback down! thank you 🙂
c

Chronos

04/19/2023, 2:39 PM
No problem, happy to help! Looks like I've solved my problems for now, thanks again!
r

rp

04/19/2023, 2:39 PM
great!