Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Catch some exceptions for wrong UIDs

Roland Geider367d102561c5
diff --git a/wger/utils/helpers.py b/wger/utils/helpers.py
index c61a36e93..87215bdab 100644
--- a/wger/utils/helpers.py
+++ b/wger/utils/helpers.py
@@ -102,7 +102,11 @@ def check_token(uidb64, token):
:return: True on success, False in all other situations
'''
if uidb64 is not None and token is not None:
- uid = urlsafe_base64_decode(uidb64)
+ try:
+ uid = int(urlsafe_base64_decode(uidb64))
+ except ValueError as e:
+ logger.info("Could not decode UID: {0}".format(e))
+ return False
user = User.objects.get(pk=uid)
if user is not None and default_token_generator.check_token(user, token):