mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-24 16:29:04 +01:00
create user: ref https://github.com/usmannasir/cyberpanel/issues/335
This commit is contained in:
@@ -54,4 +54,12 @@ class cliParser:
|
||||
parser.add_argument('--userName', help='Email Username.')
|
||||
parser.add_argument('--password', help='Email password.')
|
||||
|
||||
### Additional Arguments for user manager
|
||||
|
||||
parser.add_argument('--firstName', help='First name while creating user.')
|
||||
parser.add_argument('--lastName', help='First name while creating user.')
|
||||
parser.add_argument('--websitesLimit', help='Website limit while creating user.')
|
||||
parser.add_argument('--selectedACL', help='Select ACL while creating user.')
|
||||
parser.add_argument('--securityLevel', help='Set security level while creating user.')
|
||||
|
||||
return parser.parse_args()
|
||||
@@ -24,6 +24,7 @@ from plogical.ftpUtilities import FTPUtilities
|
||||
from plogical.sslUtilities import sslUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
from django.http import HttpRequest
|
||||
|
||||
# All that we see or seem is but a dream within a dream.
|
||||
|
||||
@@ -1323,6 +1324,61 @@ def main():
|
||||
currentversion = version + '.' + build
|
||||
print (currentversion)
|
||||
|
||||
### User Functions
|
||||
|
||||
elif args.function == "createUser":
|
||||
|
||||
completeCommandExample = 'cyberpanel createUser --firstName Cyber --lastName Panel --email email@cyberpanel.net --userName cyberpanel --password securepassword --websitesLimit 10 --selectedACL user --securityLevel HIGH'
|
||||
|
||||
if not args.firstName:
|
||||
print("\n\nPlease enter First Name. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.lastName:
|
||||
print("\n\nPlease enter Last Name. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.email:
|
||||
print("\n\nPlease enter Email. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.userName:
|
||||
print("\n\nPlease enter User name. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.password:
|
||||
print("\n\nPlease enter password. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.websitesLimit:
|
||||
print("\n\nPlease enter website limit. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.selectedACL:
|
||||
print("\n\nPlease enter select acl. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
if not args.securityLevel:
|
||||
print("\n\nPlease set security level. For example:\n\n" + completeCommandExample + "\n\n")
|
||||
return
|
||||
|
||||
from userManagment.views import submitUserCreation
|
||||
|
||||
data = {}
|
||||
data['firstName'] = args.firstName
|
||||
data['lastName'] = args.lastName
|
||||
data['email'] = args.email
|
||||
data['userName'] = args.userName
|
||||
data['password'] = args.password
|
||||
data['websitesLimit'] = args.websitesLimit
|
||||
data['selectedACL'] = args.selectedACL
|
||||
data['securityLevel'] = args.securityLevel
|
||||
data['userID'] = 1
|
||||
|
||||
response = submitUserCreation(data)
|
||||
|
||||
print(response.content.decode())
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -126,10 +126,16 @@ def submitUserCreation(request):
|
||||
try:
|
||||
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
data = json.loads(request.body)
|
||||
except:
|
||||
userID = request['userID']
|
||||
data = request
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
|
||||
data = json.loads(request.body)
|
||||
firstName = data['firstName']
|
||||
lastName = data['lastName']
|
||||
email = data['email']
|
||||
@@ -137,6 +143,7 @@ def submitUserCreation(request):
|
||||
password = data['password']
|
||||
websitesLimit = data['websitesLimit']
|
||||
selectedACL = data['selectedACL']
|
||||
|
||||
try:
|
||||
securityLevel = data['securityLevel']
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user