diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2016-01-24 04:19:23 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2016-02-02 04:22:16 +0100 |
commit | 587b79a8470a0c069f1b1d81e01685baa5e6a39b (patch) | |
tree | 1ad93770716feb361443d33747337d2d16df36bc /accounts/utils | |
parent | 5e7e7fc832d26178a6036ed483fe3cfffe2b22b2 (diff) | |
download | web-587b79a8470a0c069f1b1d81e01685baa5e6a39b.tar.gz web-587b79a8470a0c069f1b1d81e01685baa5e6a39b.tar.bz2 web-587b79a8470a0c069f1b1d81e01685baa5e6a39b.zip |
Use consistent exceptions for all user backends
Now all backends raise custom exception types and does not
forward the internal exception types. So there is no need
to import the ldap module in other modules.
Diffstat (limited to 'accounts/utils')
-rw-r--r-- | accounts/utils/__init__.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/accounts/utils/__init__.py b/accounts/utils/__init__.py index 1538fd6..2b0f566 100644 --- a/accounts/utils/__init__.py +++ b/accounts/utils/__init__.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import hmac import importlib -import ldap import pickle import re import struct @@ -70,9 +69,8 @@ def login_user(username, password): try: g.user = current_app.user_backend.auth(username, password) - except ldap.INVALID_CREDENTIALS: - return False - except ldap.NO_SUCH_OBJECT: + except (current_app.user_backend.NoSuchUserError, + current_app.user_backend.InvalidPasswordError): return False session['username'] = username |