Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Request processed" on register but nothing in the db #10

Closed
Karalix opened this issue May 24, 2021 · 3 comments
Closed

"Request processed" on register but nothing in the db #10

Karalix opened this issue May 24, 2021 · 3 comments

Comments

@Karalix
Copy link

Karalix commented May 24, 2021

Hi ! I have been testing SuperLogin over the weekend for an upcoming project but it seems I have reached a blocking point.

I am trying to make the code example from the README work with my instance of CouchDB on my distant server.

The /register POST seems OK

curl --request POST \
  --url http://localhost:3000/auth/register \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data '={
  "name": "Joe Smith",
  "username": "joesmith",
  "email": "joesmith@example.com",
  "password": "bigsecret",
  "confirmPassword": "bigsecret"
}'

{
  "success": "Request processed."
}

but then there is nothing appearing in the Fauxton and of course the next step gives me some kind of error

curl --request POST \
  --url http://localhost:3000/auth/login \
  --header 'Authorization: Basic am9lc21pdGg6Ymlnc2VjcmV0'

{
  "message": "Missing credentials"
}

And the CLI doesn't help me much as there is no error message at all, only POST /auth/register 200 516.158 ms - 32

On the CouchDB logs, there is only this POST /sl-users/_find 200 ok 5 when I perform the request.

My SuperLogin config is as following :

{
  dbServer: {
    protocol: 'https://',
    host: 'krlx.ovh:6984',
    user: 'admin',
    password: 'redacted',
    userDB: 'sl-users',
    couchAuthDB: '_users'
  },
  mailer: {
    fromEmail: 'alixducros@gmail.com',
    options: {
      service: 'Gmail',
      auth: {
        user: 'alixducros@gmail.com',
        pass: 'redacted'
      }
    }
  },
  userDBs: {
    defaultDBs: {
      private: ['supertest']
    }
  }
}
CouchDB 3.1.1
SuperLogin 0.14.1
Node 14

Maybe you have an idea of what I did wrong ? Anyway thanks for maintaining this project.

@fynnlyte
Copy link
Collaborator

Hi,

If you want to use application/x-www-form-urlencoded your request would need to look like this, which works for me with your setup:

curl --request POST \
  --url http://localhost:3000/auth/register \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'email=joesmith@example.com' \
  --data-urlencode 'password=bigsecret' \
 --data-urlencode 'confirmPassword=bigsecret'

Or you can simply use application/json instead:

curl --request POST \
  --url http://localhost:3000/auth/register \
  --header 'Content-Type: application/json' \                 
  --data '{"email": "joesmith@example.com", "password": "bigsecret", "confirmPassword": "bigsecret"}'

Nevertheless, I should add some logs and return an error if the validation fails with anything else than an email being in use.

@Karalix
Copy link
Author

Karalix commented May 24, 2021

I works perfectly now and I feel pretty stupid for mixing urlencoded with my json object 😓

Would you welcome a pull request to make the Readme a bit more verbose/exhaustive around this part ?

@Karalix Karalix closed this as completed May 24, 2021
@fynnlyte
Copy link
Collaborator

No worries, thanks for reporting. There should have been a Validation Error as answer, not a 200: request processed. The example part is a bit outdated anyway's, I'll update it together with my fix.

fynnlyte added a commit that referenced this issue May 24, 2021
- Reject with 400 if any errors other than an already existing email occurr
- Improved onboarding docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants