Automatic sign up + login from javascript client

(Kofifus) #1

Newbe question here, I searched the forum but could not find a clear answer.

My scenario is simple and I would imagine reasonably common.

I have a server-less javascript client application (working with a no-sql cloud db). So all my code runs in javascript on the user’s browser client.

Users go through a registration process on my site. At the end of that process the javascript browser client holds the email/password the user registered with (after passing email verification etc). At this point I want to automatically register the user to my linked discourse domain. I want to do that from the client using javascript without any more prompts to the user.

After registration is done and the user logs in with the credentials he registered, The javascript browser client now holds the email/password used to log in. I now want my help page to provide a link that will directly logs the user to my discourse domain so he can log an issue etc.

Is this possible ?

If yes is there any existing code/directions for this ?

Thank you!

(Robin Ward) #2

This is unfortunately not going to be easy and I’m not sure it can be done securely.

You will have to make a request to the create account end point with the appropriate information.

It is more complicated because you will need to fetch our honeypot challenge value and process it, as well as a CSRF token. The security of those are questionable if you enable CORS but you might be able to make it work.