mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-15 17:56:12 +01:00
Update views.py
This commit is contained in:
35
api/views.py
35
api/views.py
@@ -19,6 +19,7 @@ from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
|||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from userManagment.views import submitUserCreation as suc
|
from userManagment.views import submitUserCreation as suc
|
||||||
|
from userManagment.views import submitUserDeletion as duc
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@@ -119,7 +120,6 @@ def changeUserPassAPI(request):
|
|||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
|
||||||
websiteOwner = data['websiteOwner']
|
websiteOwner = data['websiteOwner']
|
||||||
ownerPassword = data['ownerPassword']
|
ownerPassword = data['ownerPassword']
|
||||||
|
|
||||||
@@ -155,6 +155,37 @@ def changeUserPassAPI(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
def submitUserDeletion(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):
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
return duc(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 as msg:
|
||||||
|
data_ret = {'submitUserDeletion': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def changePackageAPI(request):
|
def changePackageAPI(request):
|
||||||
try:
|
try:
|
||||||
@@ -189,8 +220,6 @@ def changePackageAPI(request):
|
|||||||
website.package = pack
|
website.package = pack
|
||||||
website.save()
|
website.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data_ret = {'changePackage': 1, 'error_message': "None"}
|
data_ret = {'changePackage': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user