Skip to content

Commit fb04e6d

Browse files
committed
Prevent access env directly when login
1 parent 107c804 commit fb04e6d

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ EXAMPLE
175175
Login as HMD successfully!
176176
```
177177

178-
Alternatively, you may supply an email and password via the `CMD_EMAIL` and `CMD_PASSWORD` environment variables, respectively.
178+
Alternatively, you may supply an email and password via the `CMD_CLI_ID` and `CMD_CLI_PASSWORD` environment variables, respectively.
179179

180180
_See code: [src/commands/login.ts](https://github.com/hackmdio/codimd-cli/blob/v1.0.3/src/commands/login.ts)_
181181

src/commands/login.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Command, flags} from '@oclif/command'
22
import * as inquirer from 'inquirer'
33

44
import {APIClient} from '../api'
5+
import config from '../config'
56

67
export default class Login extends Command {
78
static description = 'Login HackMD instance from CLI'
@@ -25,8 +26,8 @@ Login as HMD successfully!
2526
async run() {
2627
const {flags} = this.parse(Login)
2728

28-
let id = flags.id || process.env.CMD_CLI_ID
29-
let password = process.env.CMD_CLI_PASSWORD || ''
29+
let id = flags.id || config.loginID
30+
let password = config.loginPassword || ''
3031

3132
if (!id) {
3233
if (flags.ldap) {

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const envConfig = {
3333
? true
3434
: (process.env.CMD_CLI_COOKIE_PATH || process.env.CMD_CLI_SERVER_URL)
3535
? false
36-
: toBooleanConfig(process.env.HMD_CLI_ENTERPRISE)
36+
: toBooleanConfig(process.env.HMD_CLI_ENTERPRISE),
37+
loginID: process.env.HMD_CLI_ID || process.env.CMD_CLI_ID,
38+
loginPassword: process.env.HMD_CLI_PASSWORD || process.env.CMD_CLI_PASSWORD
3739
}
3840

3941
// look for a readable config file; we can merge it with the env.

0 commit comments

Comments
 (0)