forked from netlify/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogout.js
More file actions
36 lines (27 loc) · 922 Bytes
/
Copy pathlogout.js
File metadata and controls
36 lines (27 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Command = require('../utils/command')
const { track } = require('../utils/telemetry')
class LogoutCommand extends Command {
async run() {
const [accessToken, location] = this.getConfigToken()
if (!accessToken) {
this.log(`Already logged out`)
this.log()
this.log('To login run "netlify login"')
this.exit()
}
await track('user_logout')
// unset userID without deleting key
this.netlify.globalConfig.set('userId', null)
if (location === 'env') {
this.log('The "process.env.NETLIFY_AUTH_TOKEN" is still set in your terminal session')
this.log()
this.log('To logout completely, unset the environment variable')
this.log()
this.exit()
}
this.log(`Logging you out of Netlify. Come back soon!`)
}
}
LogoutCommand.description = `Logout of your Netlify account`
LogoutCommand.hidden = true
module.exports = LogoutCommand