mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
[API CHANGE]
Add a new API call to the sysadm/users framework as well as add a bunch more output to current users requests (error/success reporting instead of just the overall good/bad flag).
New API call: "action":"userdelete"
REQUIRED: "name":<username>
OPTIONAL: "clean_home"="true/false" (default is "true")
REST Request (example):
-------------------------------
PUT /sysadm/users
{
"name" : "test",
"action" : "userdelete"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"name" : "users",
"args" : {
"action" : "userdelete",
"name" : "test"
},
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"result": "success"
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -911,6 +911,19 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUserRequest(bool allaccess,
|
||||
}else if(action=="useradd" && allaccess){ //requires all access to create new users
|
||||
ok = sysadm::UserManager::addUser(out, in_args.toObject());
|
||||
|
||||
}else if(action=="userdelete" && allaccess){ //requires all access to remove users
|
||||
//REQUIRED: "name"
|
||||
//OPTIONAL: "clean_home"="false" (true by default)
|
||||
QString deluser = in_args.toObject().value("name").toString();
|
||||
if(deluser != user){ //cannot delete the currently-used user
|
||||
bool clean = true;
|
||||
if(in_args.toObject().contains("clean_home")){ clean = (in_args.toObject().value("clean_home").toString().toLower() == "false"); }
|
||||
ok = sysadm::UserManager::removeUser(deluser, clean);
|
||||
if(ok){ out->insert("result","success"); }
|
||||
else{ out->insert("error","Could not delete user"); }
|
||||
}else{
|
||||
out->insert("error","Cannot delete the current user");
|
||||
}
|
||||
}
|
||||
return (ok ? RestOutputStruct::OK : RestOutputStruct::BADREQUEST);
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// ===============================
|
||||
// Slots for long running Library Tasks
|
||||
// Available under the 3-clause BSD License
|
||||
// Written by: Kris Moore <kris@pcbsd.org> FEB 2016
|
||||
// =================================
|
||||
#include <WebSocket.h>
|
||||
#define DEBUG 0
|
||||
|
||||
|
||||
// Iohyve Fetch is done
|
||||
void WebSocket::slotIohyveFetchDone(QString id, int retcode, QString log)
|
||||
{
|
||||
qDebug() << "Fetch Done" << id << retcode << log;
|
||||
}
|
||||
|
||||
// Iohyve Fetch has output to read
|
||||
void WebSocket::slotIohyveFetchProcessOutput(QString output)
|
||||
{
|
||||
qDebug() << "Fetch Do" << output;
|
||||
}
|
||||
@@ -111,8 +111,8 @@ private slots:
|
||||
void SslError(const QList<QSslError>&); //sslErrors() signal
|
||||
|
||||
// Library Slots
|
||||
void slotIohyveFetchDone(QString, int, QString);
|
||||
void slotIohyveFetchProcessOutput(QString);
|
||||
//void slotIohyveFetchDone(QString, int, QString);
|
||||
//void slotIohyveFetchProcessOutput(QString);
|
||||
|
||||
//Bridge Connection Handling
|
||||
void startBridgeAuth();
|
||||
|
||||
@@ -19,7 +19,6 @@ SOURCES += main.cpp \
|
||||
WebSocket.cpp \
|
||||
RestStructs.cpp \
|
||||
WebBackend.cpp \
|
||||
WebBackendSlots.cpp \
|
||||
AuthorizationManager.cpp \
|
||||
EventWatcher.cpp \
|
||||
LogManager.cpp \
|
||||
|
||||
Reference in New Issue
Block a user