adrien2p / medusa-plugins

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

Conditionally redirecting to Auth0 Sign Up Page #135

Open emily-foraged opened 5 months ago

emily-foraged commented 5 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 5 months ago

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

emily-foraged commented 3 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 3 months ago

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