Skip to content

Commit 3531f55

Browse files
committed
add remote access
1 parent 13e0011 commit 3531f55

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

cloudAPI/views.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from .cloudManager import CloudManager
55
import json
66
from loginSystem.models import Administrator
7-
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
87
from django.views.decorators.csrf import csrf_exempt
8+
from django.shortcuts import HttpResponse
99

1010
@csrf_exempt
1111
def router(request):
@@ -314,25 +314,21 @@ def router(request):
314314
@csrf_exempt
315315
def access(request):
316316
try:
317-
data = json.loads(request.body)
318-
319317
serverUserName = request.GET.get('serverUserName')
320318
token = request.GET.get('token')
321319

322320
admin = Administrator.objects.get(userName=serverUserName)
323321

324-
cm = CloudManager(data, admin)
325-
326322
if admin.api == 0:
327-
return cm.ajaxPre(0, 'API Access Disabled.')
323+
return HttpResponse('API Access Disabled.')
328324

329-
if token == admin.token.lstrip('Basic '):
325+
if token == admin.token.lstrip('Basic ').rstrip('='):
330326
request.session['userID'] = admin.pk
331327
from django.shortcuts import redirect
332328
from baseTemplate.views import renderBase
333329
return redirect(renderBase)
334330
else:
335-
return cm.ajaxPre(0, 'Unauthorized access.')
331+
return HttpResponse('Unauthorized access.')
336332

337333
except BaseException as msg:
338334
cm = CloudManager(None)

0 commit comments

Comments
 (0)