Skip to content
Permalink
Browse files

api: submitUserCreation

  • Loading branch information
usmannasir committed Dec 6, 2019
1 parent 1492fcd commit 746b5ae71788c585bca2e9c51281b0ae62f2c016
Showing with 34 additions and 1 deletion.
  1. +1 −0 api/urls.py
  2. +33 −1 api/views.py
@@ -23,5 +23,6 @@

url(r'^cyberPanelVersion', views.cyberPanelVersion, name='cyberPanelVersion'),
url(r'^runAWSBackups$', views.runAWSBackups, name='runAWSBackups'),
url(r'^submitUserCreation$', views.submitUserCreation, name='submitUserCreation'),

]
@@ -18,6 +18,7 @@
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities
from django.views.decorators.csrf import csrf_exempt
from userManagment.views import submitUserCreation
# Create your views here.

@csrf_exempt
@@ -590,4 +591,35 @@ def runAWSBackups(request):
s3 = S3Backups(request, None, 'runAWSBackups')
s3.start()
except BaseException, msg:
logging.writeToFile(str(msg) + ' [API.runAWSBackups]')
logging.writeToFile(str(msg) + ' [API.runAWSBackups]')


@csrf_exempt
def submitUserCreation(request):
try:
if request.method == 'POST':

data = json.loads(request.body)

adminUser = data['adminUser']
adminPass = data['adminPass']

admin = Administrator.objects.get(userName=adminUser)

if admin.api == 0:
data_ret = {"status": 0, 'error_message': "API Access Disabled."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

if hashPassword.check_password(admin.password, adminPass):
return submitUserCreation(request)
else:
data_ret = {"status": 0,
'error_message': "Could not authorize access to API"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

except BaseException, msg:
data_ret = {'changeStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

0 comments on commit 746b5ae

Please sign in to comment.
You can’t perform that action at this time.