-
Hi there, I'd love the ability to log a user into their Swell account from the server, specifically within a middleware file (Nextjs app router). We're using Swell to add a subscription service to our app, in conjunction with Auth0 for authentication. A user selects their plan on the app, is redirected to a hosted Auth0 sign-up page, and then redirected back to our app. The middleware steps in here and handles everything Swell, it...
At this point I have to redirect to a temp page in my app, log the user in to Swell and then redirect to the Swell-hosted checkout (Plan page > Auth0 > Middleware > Temp page > Swell Checkout). Ideally, I'd like to log the user into their Swell account using some tokenised login server side, and then redirect directly to the Swell-hosted checkout (Plan page > Auth0 > Middleware > Swell Checkout). Not being able to authenticate server-side adds a whole lot of extra time to the process, handling the login and redirect seems to take a while on the temp page. I'm pretty desperate for a solution to this, so any help would be really appreciated. Thanks so much! Mark |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can use Swell.js on the server, which will create/update a cookie that should be sent back to the browser allowing the customer to be authenticated by the next step. Have you tried that? |
Beta Was this translation helpful? Give feedback.
@Ojay The only other way would be through
swell-node
, you can do something like this but it only works with a password:It should return an account record if available, or
null
if not found. But then you would have to manage the auth session.