1 | 'use strict';
|
2 |
|
3 | const cli = require('heroku-cli-util');
|
4 |
|
5 | module.exports = function* (context, heroku, on) {
|
6 | let account = yield heroku.get('/account');
|
7 | if (on && account.two_factor_authentication || !on && !account.two_factor_authentication) {
|
8 | let enabled = account.two_factor_authentication ? 'enabled' : 'disabled';
|
9 | throw new Error(`Two-factor authentication is already ${enabled}`);
|
10 | } else {
|
11 | let password = yield cli.prompt('Password', { hide: true });
|
12 | let body = { password, two_factor_authentication: on };
|
13 | let account = yield heroku.patch('/account', { body });
|
14 | let enabled = account.two_factor_authentication ? 'enabled' : 'disabled';
|
15 | cli.log(`Two-factor authentication has been ${enabled}`);
|
16 | }
|
17 | }; |
\ | No newline at end of file |