Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Separate login and adduser #135

Open
finnp opened this issue Apr 7, 2016 · 2 comments
Open

Separate login and adduser #135

finnp opened this issue Apr 7, 2016 · 2 comments

Comments

@finnp
Copy link

finnp commented Apr 7, 2016

Hey :)

I would like to use the client to login, but I don't want accidental accounts creations (see npm/npm#8337).

I was thinking of factoring out the login part and (potentially using it within adduser). So that adduser would stay the same, but login would not create an account.

What do you think? I could start a PR for this.

@finnp
Copy link
Author

finnp commented Apr 7, 2016

Okay, I thought this was an issue with the library/CLI. But now it seems like it's an issue of the registry. Maybe someone can help me figure this out.

@finnp
Copy link
Author

finnp commented Apr 8, 2016

If I remove the email from the request. The login will still work, but the signup will fail. So it would actually be possible to separate those.

Here's the code I use for login:

  var userobj = {
    _id: 'org.couchdb.user:' + username,
    name: username,
    password: password,
    type: 'user',
    roles: [],
    date: new Date().toISOString()
  }

  var uri = url.resolve(registry, '-/user/org.couchdb.user:' + encodeURIComponent(username))
  var options = {
    method: 'PUT',
    body: userobj
  }
  client.request(uri, options, function (error, data, json, response) {
    if (error) return cb(error)
    if (!data.token) return cb(new Error('No token returned.'))

    cb(null, data.token)
  })

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant