I’m working on a little c# utility to move users from an existing forum into Discourse. I have the code working to add a single user. However when I call the code a second time I get an error that “Signup is not allowed from this account.”.
Apparently after you call the API to create a new account, it switches you to that account. I’ve tried starting the API calls over at the beginning. I’ve tried keeping the same forum session from my first call when I was logged in as the admin user. Here’s my workflow:
- Call the forum general URL once with the api_key and api_username and save the cookie I get back.
- For each user I’m trying to add:
(a) GET /users/hp.json and save the two values returned
(b) GET /session/csrf.json and save the value returned
© POST /users with the assorted values from above.
The first user goes through just fine and I get the confirmation email. The second user fails with “Signup is not allowed from this account.”
I’ve tried reusing the API key and API username in the POST to /users but that didn’t help.
Is what I’m doing even possible?
My best guess is the POSTing to /users resets the _forum_session cookie to the new user and I’m not completely resetting it back to what it should be. Does that sound reasonable?