mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Give a helpful error if API key is wrong length
Trac #1680 (imported from commit 0a50e7a93b37a5a3e74fb99c97a8917d8fbcc8f9)
This commit is contained in:
@@ -73,7 +73,11 @@ def validate_api_key(email, api_key):
|
|||||||
except UserProfile.DoesNotExist:
|
except UserProfile.DoesNotExist:
|
||||||
raise JsonableError("Invalid user: %s" % (email,))
|
raise JsonableError("Invalid user: %s" % (email,))
|
||||||
if api_key != user_profile.api_key:
|
if api_key != user_profile.api_key:
|
||||||
raise JsonableError("Invalid API key for user '%s'" % (email,))
|
if len(api_key) != 32:
|
||||||
|
reason = "Incorrect API key length (keys should be 32 characters long)"
|
||||||
|
else:
|
||||||
|
reason = "Invalid API key"
|
||||||
|
raise JsonableError(reason + " for user '%s'" % (email,))
|
||||||
if not user_profile.is_active:
|
if not user_profile.is_active:
|
||||||
raise JsonableError("User account is not active")
|
raise JsonableError("User account is not active")
|
||||||
return user_profile
|
return user_profile
|
||||||
|
|||||||
Reference in New Issue
Block a user