adrien2p / medusa-plugins

A collection of awesome plugins for medusa :rocket:
https://medusa-plugins.vercel.app
MIT License
161 stars 46 forks source link

Conditionally redirecting to Auth0 Sign Up Page #135

Open emily-foraged opened 10 months ago

emily-foraged commented 10 months ago

Is there a way to have medusa-plugin-auth/Passport conditionally redirect users to the Auth0 sign up page rather than to the login page? It looks like if you pass ?screen_hint=signup to the Auth0 /authorize endpoint, users will be routed to the signup page (source). Unsure if there's a way to configure that query parameter within our Medusa app and pass it all the way through to the actual Auth0 url right now though.

adrien2p commented 9 months ago

I am not sure but open to investigation in order to see if we could do it.

emily-foraged commented 8 months ago

Hey @adrien2p! I think I found a way to do this! I think we'd just need to replace the call to passport.authenticate on L79 in auth-routes-builder.ts with something like:

(req, res, next) => {
            const { screen_hint } = req.query;
            const authenticate = passport.authenticate(strategyName, {
                ...passportAuthenticateMiddlewareOptions,
                session: false,
                screen_hint: screen_hint === 'signup' ? 'signup' : '',
            });
            authenticate(req, res, next);
}

I tried to push a branch to repo to open a PR but it seems to be stalling. I fond the contribution instructions but am not totally sure what they're asking of me - should I be forking the repo and opening a PR against the fork?

adrien2p commented 8 months ago

Sounds super cool, yes you need to and open a pr 👍