File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import { getRandomPort } from 'get-port-please'
6
6
import { listen } from 'listhen'
7
7
import { withQuery , joinURL } from 'ufo'
8
8
import { NUXT_HUB_URL } from '../utils.mjs'
9
- import whoami from './whoami.mjs'
10
9
11
10
export default defineCommand ( {
12
11
meta : {
@@ -19,7 +18,10 @@ export default defineCommand({
19
18
}
20
19
const config = loadConfig ( )
21
20
if ( config . token ) {
22
- return runCommand ( whoami , { } )
21
+ const user = await $api ( '/user' ) . catch ( ( ) => null )
22
+ if ( user ?. name ) {
23
+ return consola . info ( `Already logged in as \`${ user . name } \`` )
24
+ }
23
25
}
24
26
// Create server for OAuth flow
25
27
let listener
@@ -32,7 +34,11 @@ export default defineCommand({
32
34
const token = getQuery ( event ) . token
33
35
34
36
if ( token ) {
35
- const user = await $api ( '/user' ) . catch ( ( ) => null )
37
+ const user = await $api ( '/user' , {
38
+ headers : {
39
+ Authorization : `token ${ token } `
40
+ }
41
+ } ) . catch ( ( ) => null )
36
42
if ( user ?. name ) {
37
43
writeConfig ( { token } )
38
44
consola . success ( 'Authenticated successfully!' )
You can’t perform that action at this time.
0 commit comments