Skip to content

Commit

Permalink
lockedValue validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Damico committed May 27, 2021
1 parent f34c053 commit b7eef0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions LDlink/LDlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,21 @@ def unblock_user():
@requires_admin_token
def set_user_lock():
print("Execute api unlock user")
email = request.args.get('email', False)
lockValue = request.args.get('locked', False)
out_json = setUserLock(email, lockValue)
email = request.args.get('email', "Missing Argument")

try:
lockValue = int(request.args.get('locked', "Missing Argument"))
if lockValue == -1 or lockValue == 0:
out_json = setUserLock(email, lockValue)
else:
out_json = {
"message": "invalid lock value: " + str(lockValue)
}
except:
out_json = {
"message": "invalid lock value"
}

return sendJSON(out_json)

# Web route to unlock all users API tokens
Expand Down
2 changes: 1 addition & 1 deletion LDlink/RegisterAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def unblockUser(email):
emailUserUnblocked(email, email_account)
return out_json

# sets locked attribute of user to 0=false
# sets locked attribute of user to lockValue
def setUserLock(email, lockValue):
with open('config.yml', 'r') as f:
config = yaml.load(f)
Expand Down

0 comments on commit b7eef0a

Please sign in to comment.