@@ -8,16 +8,27 @@ const adduser = async (npm, { creds, ...opts }) => {
88 const authType = npm . config . get ( 'auth-type' )
99 let res
1010 if ( authType === 'web' ) {
11- res = await profile . adduserWeb ( ( url , emitter ) => {
12- openUrlPrompt (
13- npm ,
14- url ,
15- 'Create your account at' ,
16- 'Press ENTER to open in the browser...' ,
17- emitter
18- )
19- } , opts )
20- } else {
11+ try {
12+ res = await profile . adduserWeb ( ( url , emitter ) => {
13+ openUrlPrompt (
14+ npm ,
15+ url ,
16+ 'Create your account at' ,
17+ 'Press ENTER to open in the browser...' ,
18+ emitter
19+ )
20+ } , opts )
21+ } catch ( err ) {
22+ if ( err . code === 'ENYI' ) {
23+ log . verbose ( 'web add user not supported, trying couch' )
24+ } else {
25+ throw err
26+ }
27+ }
28+ }
29+
30+ // auth type !== web or ENYI error w/ web adduser
31+ if ( ! res ) {
2132 const username = await read . username ( 'Username:' , creds . username )
2233 const password = await read . password ( 'Password:' , creds . password )
2334 const email = await read . email ( 'Email: (this IS public) ' , creds . email )
@@ -44,16 +55,27 @@ const login = async (npm, { creds, ...opts }) => {
4455 const authType = npm . config . get ( 'auth-type' )
4556 let res
4657 if ( authType === 'web' ) {
47- res = await profile . loginWeb ( ( url , emitter ) => {
48- openUrlPrompt (
49- npm ,
50- url ,
51- 'Login at' ,
52- 'Press ENTER to open in the browser...' ,
53- emitter
54- )
55- } , opts )
56- } else {
58+ try {
59+ res = await profile . loginWeb ( ( url , emitter ) => {
60+ openUrlPrompt (
61+ npm ,
62+ url ,
63+ 'Login at' ,
64+ 'Press ENTER to open in the browser...' ,
65+ emitter
66+ )
67+ } , opts )
68+ } catch ( err ) {
69+ if ( err . code === 'ENYI' ) {
70+ log . verbose ( 'web login not supported, trying couch' )
71+ } else {
72+ throw err
73+ }
74+ }
75+ }
76+
77+ // auth type !== web or ENYI error w/ web login
78+ if ( ! res ) {
5779 const username = await read . username ( 'Username:' , creds . username )
5880 const password = await read . password ( 'Password:' , creds . password )
5981 res = await otplease ( npm , opts , ( reqOpts ) =>
0 commit comments