mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
API CHANGE
Add new "usermod" action to the sysadm/users class. This is nearly identical to the "useradd" action, but performs changes to an existing user only (limited access users may modify their own settings, but not other users settings).
Additional OPTIONAL input: "newname" change the username to this instead.
REST Request (example):
-------------------------------
PUT /sysadm/users
{
"action" : "usermod",
"comment" : "somecomment",
"name" : "test2"
}
WebSocket Request:
-------------------------------
{
"name" : "users",
"namespace" : "sysadm",
"args" : {
"name" : "test2",
"comment" : "somecomment",
"action" : "usermod"
},
"id" : "fooid"
}
Response:
-------------------------------
{
"args": {
"result": "success"
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -924,6 +924,16 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUserRequest(bool allaccess,
|
||||
}else{
|
||||
out->insert("error","Cannot delete the current user");
|
||||
}
|
||||
|
||||
}else if(action=="usermod"){
|
||||
bool go = true;
|
||||
if(!allaccess){
|
||||
//ensure that the user being acted on is the current user - otherwise deny access
|
||||
go = (in_args.toObject().value("name").toString() == user);
|
||||
}
|
||||
if(go){ ok = sysadm::UserManager::modifyUser(out, in_args.toObject() ); }
|
||||
}
|
||||
|
||||
|
||||
return (ok ? RestOutputStruct::OK : RestOutputStruct::BADREQUEST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user