Prevent score lowering
This commit is contained in:
parent
9ec1f6239d
commit
cb755e771c
5
model.py
5
model.py
@ -85,7 +85,10 @@ class Model(object):
|
|||||||
async def set_score(self, authtoken, newscore):
|
async def set_score(self, authtoken, newscore):
|
||||||
user = self.verify_user(authtoken)
|
user = self.verify_user(authtoken)
|
||||||
if newscore <= user.maxscore:
|
if newscore <= user.maxscore:
|
||||||
user.score = newscore
|
if newscore < user.score:
|
||||||
|
raise Exception("Tried to lower its score")
|
||||||
|
else:
|
||||||
|
user.score = newscore
|
||||||
else:
|
else:
|
||||||
raise Exception("Tried to raise user score above maxscore")
|
raise Exception("Tried to raise user score above maxscore")
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"bd63gy2wfdk72q3mk6ooesanx4mo33ao": {
|
"bd63gy2wfdk72q3mk6ooesanx4mo33ao": {
|
||||||
"uuid": "bd63gy2wfdk72q3mk6ooesanx4mo33ao",
|
"uuid": "bd63gy2wfdk72q3mk6ooesanx4mo33ao",
|
||||||
"name": "Felix",
|
"name": "Felix",
|
||||||
"score": 276,
|
"score": 285,
|
||||||
"maxscore": 300,
|
"maxscore": 300,
|
||||||
"timeout": 0
|
"timeout": 0
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user