+ oputil user rename
This commit is contained in:
parent
83d0daf4b7
commit
f41d12c688
|
@ -30,6 +30,8 @@ actions:
|
||||||
aliases: password, passwd
|
aliases: password, passwd
|
||||||
rm USERNAME permanently removes user from system
|
rm USERNAME permanently removes user from system
|
||||||
aliases: remove, delete, del
|
aliases: remove, delete, del
|
||||||
|
rename USERNAME NEWNAME rename a user
|
||||||
|
aliases: mv
|
||||||
activate USERNAME set status to active
|
activate USERNAME set status to active
|
||||||
deactivate USERNAME set status to inactive
|
deactivate USERNAME set status to inactive
|
||||||
disable USERNAME set status to disabled
|
disable USERNAME set status to disabled
|
||||||
|
|
|
@ -227,6 +227,41 @@ function removeUser(user) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renameUser(user) {
|
||||||
|
if(argv._.length < 3) {
|
||||||
|
return printUsageAndSetExitCode(getHelpFor('User'), ExitCodes.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const newUserName = argv._[argv._.length - 1];
|
||||||
|
|
||||||
|
async.series(
|
||||||
|
[
|
||||||
|
(callback) => {
|
||||||
|
const { validateUserNameAvail } = require('../../core/system_view_validate.js');
|
||||||
|
return validateUserNameAvail(newUserName, callback);
|
||||||
|
},
|
||||||
|
(callback) => {
|
||||||
|
const userDb = require('../../core/database.js').dbs.user;
|
||||||
|
userDb.run(
|
||||||
|
`UPDATE user
|
||||||
|
SET user_name = ?
|
||||||
|
WHERE id = ?;`,
|
||||||
|
[ newUserName, user.userId, ],
|
||||||
|
err => {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
err => {
|
||||||
|
if(err) {
|
||||||
|
return console.error(err.reason ? err.reason : err.message);
|
||||||
|
}
|
||||||
|
return console.info(`User "${user.username}" renamed to "${newUserName}"`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function modUserGroups(user) {
|
function modUserGroups(user) {
|
||||||
if(argv._.length < 3) {
|
if(argv._.length < 3) {
|
||||||
return printUsageAndSetExitCode(getHelpFor('User'), ExitCodes.ERROR);
|
return printUsageAndSetExitCode(getHelpFor('User'), ExitCodes.ERROR);
|
||||||
|
@ -317,9 +352,13 @@ function handleUserCommand() {
|
||||||
return errUsage();
|
return errUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
const action = argv._[1];
|
const action = argv._[1];
|
||||||
const usernameIdx = [ 'pw', 'pass', 'passwd', 'password', 'group' ].includes(action) ? argv._.length - 2 : argv._.length - 1;
|
const usernameIdx = [
|
||||||
const userName = argv._[usernameIdx];
|
'pw', 'pass', 'passwd', 'password',
|
||||||
|
'group',
|
||||||
|
'mv', 'rename'
|
||||||
|
].includes(action) ? argv._.length - 2 : argv._.length - 1;
|
||||||
|
const userName = argv._[usernameIdx];
|
||||||
|
|
||||||
if(!userName) {
|
if(!userName) {
|
||||||
return errUsage();
|
return errUsage();
|
||||||
|
@ -341,6 +380,9 @@ function handleUserCommand() {
|
||||||
del : removeUser,
|
del : removeUser,
|
||||||
delete : removeUser,
|
delete : removeUser,
|
||||||
|
|
||||||
|
mv : renameUser,
|
||||||
|
rename : renameUser,
|
||||||
|
|
||||||
activate : setAccountStatus,
|
activate : setAccountStatus,
|
||||||
deactivate : setAccountStatus,
|
deactivate : setAccountStatus,
|
||||||
disable : setAccountStatus,
|
disable : setAccountStatus,
|
||||||
|
|
|
@ -49,6 +49,8 @@ actions:
|
||||||
aliases: password, passwd
|
aliases: password, passwd
|
||||||
rm USERNAME permanently removes user from system
|
rm USERNAME permanently removes user from system
|
||||||
aliases: remove, delete, del
|
aliases: remove, delete, del
|
||||||
|
rename USERNAME NEWNAME rename a user
|
||||||
|
aliases: mv
|
||||||
activate USERNAME set status to active
|
activate USERNAME set status to active
|
||||||
deactivate USERNAME set status to inactive
|
deactivate USERNAME set status to inactive
|
||||||
disable USERNAME set status to disabled
|
disable USERNAME set status to disabled
|
||||||
|
@ -61,6 +63,7 @@ actions:
|
||||||
| `info` | Display user information| `./oputil.js user info joeuser` | N/A |
|
| `info` | Display user information| `./oputil.js user info joeuser` | N/A |
|
||||||
| `pw` | Set password | `./oputil.js user pw joeuser s3cr37` | `passwd`, `password` |
|
| `pw` | Set password | `./oputil.js user pw joeuser s3cr37` | `passwd`, `password` |
|
||||||
| `rm` | Removes user | `./oputil.js user del joeuser` | `remove`, `del`, `delete` |
|
| `rm` | Removes user | `./oputil.js user del joeuser` | `remove`, `del`, `delete` |
|
||||||
|
| `rename` | Renames a user | `./oputil.js user rename joeuser joe` | `mv` |
|
||||||
| `activate` | Activates user | `./oputil.js user activate joeuser` | N/A |
|
| `activate` | Activates user | `./oputil.js user activate joeuser` | N/A |
|
||||||
| `deactivate` | Deactivates user | `./oputil.js user deactivate joeuser` | N/A |
|
| `deactivate` | Deactivates user | `./oputil.js user deactivate joeuser` | N/A |
|
||||||
| `disable` | Disables user (user will not be able to login) | `./oputil.js user disable joeuser` | N/A |
|
| `disable` | Disables user (user will not be able to login) | `./oputil.js user disable joeuser` | N/A |
|
||||||
|
|
|
@ -1985,9 +1985,6 @@
|
||||||
submit: true
|
submit: true
|
||||||
argName: message
|
argName: message
|
||||||
}
|
}
|
||||||
TL6: {
|
|
||||||
// theme me!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
submit: {
|
submit: {
|
||||||
*: [
|
*: [
|
||||||
|
|
Loading…
Reference in New Issue