Add back the login verification .. fixed thanks to Can
This commit is contained in:
1 parent
2c220ad635
commit
bfc0c8957f
2 files changed
+18
-21
No files matched your search
+2
-11
@@ -197,12 +197,7 @@ def workloadDictionary(machine, result, test):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def update(request):
|
def update(request, user):
|
||||||
|
|
||||||
# Log the user in to verify
|
|
||||||
user = authenticate(
|
|
||||||
username=request.POST['username'],
|
|
||||||
password=request.POST['password'])
|
|
||||||
|
|
||||||
# Parse the data from the worker
|
# Parse the data from the worker
|
||||||
wins = int(request.POST['wins'])
|
wins = int(request.POST['wins'])
|
||||||
@@ -230,11 +225,7 @@ def update(request):
|
|||||||
finished = passed or failed
|
finished = passed or failed
|
||||||
|
|
||||||
# Update total # of games played for the User
|
# Update total # of games played for the User
|
||||||
for profile in Profile.objects.all():
|
Profile.objects.filter(user=user).update(games=F('games') + games)
|
||||||
if profile.user.username == request.POST['username']:
|
|
||||||
profile.games += games
|
|
||||||
profile.save()
|
|
||||||
break
|
|
||||||
|
|
||||||
# Just force an update to Machine.update
|
# Just force an update to Machine.update
|
||||||
Machine.objects.filter(id=machineid).update()
|
Machine.objects.filter(id=machineid).update()
|
||||||
|
|||||||
+16
-10
@@ -352,11 +352,11 @@ def getFiles(request):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def getWorkload(request):
|
def getWorkload(request):
|
||||||
|
|
||||||
# Verify credentials
|
# Verify that we got a valid login
|
||||||
try: authenticate(
|
user = authenticate(
|
||||||
username=request.POST['username'],
|
username=request.POST['username'],
|
||||||
password=request.POST['password'])
|
password=request.POST['password'])
|
||||||
except: return HttpResponse('Bad Credentials')
|
if user == None: return HttpResponse('Bad Credentials')
|
||||||
|
|
||||||
# Create or fetch the Machine
|
# Create or fetch the Machine
|
||||||
try: machine = OpenBench.utils.getMachine(
|
try: machine = OpenBench.utils.getMachine(
|
||||||
@@ -380,11 +380,11 @@ def getWorkload(request):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def wrongBench(request):
|
def wrongBench(request):
|
||||||
|
|
||||||
# Verify credentials
|
# Verify that we got a valid login
|
||||||
try: authenticate(
|
user = authenticate(
|
||||||
username=request.POST['username'],
|
username=request.POST['username'],
|
||||||
password=request.POST['password'])
|
password=request.POST['password'])
|
||||||
except: return HttpResponse('Bad Credentials')
|
if user == None: return HttpResponse('Bad Credentials')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Find the engine with the bad bench
|
# Find the engine with the bad bench
|
||||||
@@ -409,11 +409,11 @@ def wrongBench(request):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def submitNPS(request):
|
def submitNPS(request):
|
||||||
|
|
||||||
# Verify credentials
|
# Verify that we got a valid login
|
||||||
try: authenticate(
|
user = authenticate(
|
||||||
username=request.POST['username'],
|
username=request.POST['username'],
|
||||||
password=request.POST['password'])
|
password=request.POST['password'])
|
||||||
except: return HttpResponse('Bad Credentials')
|
if user == None: return HttpResponse('Bad Credentials')
|
||||||
|
|
||||||
# Try to update the NPS for the machine
|
# Try to update the NPS for the machine
|
||||||
try:
|
try:
|
||||||
@@ -427,8 +427,14 @@ def submitNPS(request):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def submitResults(request):
|
def submitResults(request):
|
||||||
|
|
||||||
|
# Verify that we got a valid login
|
||||||
|
user = authenticate(
|
||||||
|
username=request.POST['username'],
|
||||||
|
password=request.POST['password'])
|
||||||
|
if user == None: return HttpResponse('Stop')
|
||||||
|
|
||||||
# Try to update each location
|
# Try to update each location
|
||||||
try: OpenBench.utils.update(request)
|
try: OpenBench.utils.update(request, user)
|
||||||
except: return HttpResponse('Stop')
|
except: return HttpResponse('Stop')
|
||||||
|
|
||||||
return HttpResponse('None')
|
return HttpResponse('None')
|
||||||
Reference in new issue
Block a user