adduser flow #5

Closed
fengmk2 opened this Issue Dec 4, 2013 · 1 comment

Projects

None yet

2 participants

@fengmk2
Member
fengmk2 commented Dec 4, 2013

No description provided.

@dead-horse dead-horse was assigned Dec 4, 2013
@dead-horse
Member

npm adduser (new user)

npm info it worked if it ends with ok
npm verb cli [ '/Users/deadhorse/nvm/v0.10.21/bin/node',
npm verb cli   '/Users/deadhorse/nvm/v0.10.21/bin/npm',
npm verb cli   'adduser',
npm verb cli   '--verbose' ]
npm info using npm@1.3.11
npm info using node@v0.10.21
Username: (dead_horse) dead_horse_
Password: 
Email: (dead_horse@qq.com) 
npm verb adduser before first PUT { name: 'dead_horse_',
npm verb adduser   salt: 'XXXXX',
npm verb adduser   password_sha: 'XXXXX',
npm verb adduser   email: 'dead_horse@qq.com',
npm verb adduser   _id: 'org.couchdb.user:dead_horse_',
npm verb adduser   type: 'user',
npm verb adduser   roles: [],
npm verb adduser   date: '2013-12-04T03:56:25.932Z' }
npm verb url raw /-/user/org.couchdb.user:dead_horse_
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse_' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm info trying registry request attempt 1 at 11:56:25
npm http PUT https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm http 201 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm info adduser Authorized user dead_horse_
npm verb exit [ 0, true ]
npm info ok 

npm adduser (exist user)

$ npm adduser --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/deadhorse/nvm/v0.10.21/bin/node',
npm verb cli   '/Users/deadhorse/nvm/v0.10.21/bin/npm',
npm verb cli   'adduser',
npm verb cli   '--verbose' ]
npm info using npm@1.3.11
npm info using node@v0.10.21
Username: (dead_horse_) 
Email: (dead_horse@qq.com) 
npm verb adduser before first PUT { name: 'dead_horse_',
npm verb adduser   salt: 'XXXXX',
npm verb adduser   password_sha: 'XXXXX',
npm verb adduser   email: 'dead_horse@qq.com',
npm verb adduser   _id: 'org.couchdb.user:dead_horse_',
npm verb adduser   type: 'user',
npm verb adduser   roles: [],
npm verb adduser   date: '2013-12-04T03:56:37.774Z' }
npm verb url raw /-/user/org.couchdb.user:dead_horse_
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse_' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm info trying registry request attempt 1 at 11:56:37
npm http PUT https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
dnpm http 409 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm verb adduser update existing user
npm verb url raw /-/user/org.couchdb.user:dead_horse_
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse_' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm info trying registry request attempt 1 at 11:56:39
npm http GET https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
^R
dnpm http 200 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_
npm verb adduser userobj { name: 'dead_horse_',
npm verb adduser   salt: 'XXXXX',
npm verb adduser   password_sha: 'XXXXX',
npm verb adduser   email: 'dead_horse@qq.com',
npm verb adduser   _id: 'org.couchdb.user:dead_horse_',
npm verb adduser   type: 'user',
npm verb adduser   roles: [],
npm verb adduser   date: '2013-12-04T03:56:37.774Z' }
npm verb url raw /-/user/org.couchdb.user:dead_horse_/-rev/1-f406ff8c7f880f6338d963fb8df156c6
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse_/-rev/1-f406ff8c7f880f6338d963fb8df156c6' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_/-rev/1-f406ff8c7f880f6338d963fb8df156c6
^R
npm info trying registry request attempt 1 at 11:56:42
npm http PUT https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_/-rev/1-f406ff8c7f880f6338d963fb8df156c6
npm http 201 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse_/-rev/1-f406ff8c7f880f6338d963fb8df156c6
npm info adduser Authorized user dead_horse_
npm verb exit [ 0, true ]
npm info ok 

npm adduser (wrong password)

$ npm adduser --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/deadhorse/nvm/v0.10.21/bin/node',
npm verb cli   '/Users/deadhorse/nvm/v0.10.21/bin/npm',
npm verb cli   'adduser',
npm verb cli   '--verbose' ]
npm info using npm@1.3.11
npm info using node@v0.10.21
Username: (dead_horse_) dead_horse
Password: 
Email: (dead_horse@qq.com) 
npm verb adduser before first PUT { name: 'dead_horse',
npm verb adduser   salt: 'XXXXX',
npm verb adduser   password_sha: 'XXXXX',
npm verb adduser   email: 'dead_horse@qq.com',
npm verb adduser   _id: 'org.couchdb.user:dead_horse',
npm verb adduser   type: 'user',
npm verb adduser   roles: [],
npm verb adduser   date: '2013-12-04T04:02:13.009Z' }
npm verb url raw /-/user/org.couchdb.user:dead_horse
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm info trying registry request attempt 1 at 12:02:13
npm http PUT https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm http 409 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm verb adduser update existing user
npm verb url raw /-/user/org.couchdb.user:dead_horse
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './-/user/org.couchdb.user:dead_horse' ]
npm verb url resolved https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm info trying registry request attempt 1 at 12:02:14
npm http GET https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm http 401 https://registry.npmjs.org/-/user/org.couchdb.user:dead_horse
npm verb adduser back [ [Error: unauthorized Name or password is incorrect.: -/user/org.couchdb.user:dead_horse],
npm verb adduser   { error: 'unauthorized',
npm verb adduser     reason: 'Name or password is incorrect.' },
npm verb adduser   '{"error":"unauthorized","reason":"Name or password is incorrect."}\n' ]
npm WARN adduser Incorrect username or password
npm WARN adduser You can reset your account by visiting:
npm WARN adduser 
npm WARN adduser     http://admin.npmjs.org/reset
npm WARN adduser 
npm ERR! Error: unauthorized Name or password is incorrect.: -/user/org.couchdb.user:dead_horse
npm ERR!     at RegClient.<anonymous> (/Users/deadhorse/nvm/v0.10.21/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:272:14)
npm ERR!     at Request.self.callback (/Users/deadhorse/nvm/v0.10.21/lib/node_modules/npm/node_modules/request/request.js:129:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (/Users/deadhorse/nvm/v0.10.21/lib/node_modules/npm/node_modules/request/request.js:873:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (/Users/deadhorse/nvm/v0.10.21/lib/node_modules/npm/node_modules/request/request.js:824:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 13.0.0
npm ERR! command "/Users/deadhorse/nvm/v0.10.21/bin/node" "/Users/deadhorse/nvm/v0.10.21/bin/npm" "adduser" "--verbose"
npm ERR! cwd /Users/deadhorse
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm verb exit [ 1, true ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/deadhorse/npm-debug.log
npm ERR! not ok code 0


@dead-horse dead-horse added a commit that referenced this issue Dec 4, 2013
@dead-horse dead-horse Mock npm adduser server response, fixing #5
put /-/user/:name first
if return 201 adduser ok,
else if return 409, means user exist

then get /-/user/:name with header authorization: 'Basic ZXhpc3EWdf=='
if check ok, return 200 and account info. then put/-/user/:name/-rev/:rev
if check not ok, return 401, adduser error.

adduser the same account:
It will post /_session to get authSession.
e71a283
@fengmk2 fengmk2 added a commit that closed this issue Dec 4, 2013
@fengmk2 fengmk2 adduser() finish fixed #5 d746cca
@fengmk2 fengmk2 closed this in d746cca Dec 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment