From 48a090c20f0d4b53fa8fa1e4a5537c7cb31b5478 Mon Sep 17 00:00:00 2001 From: vapao Date: Mon, 9 Mar 2020 13:43:05 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E6=9B=B4=E6=96=B0ldap=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/account/views.py | 2 ++ spug_api/libs/ldap.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spug_api/apps/account/views.py b/spug_api/apps/account/views.py index a5d7988..41a8bbb 100644 --- a/spug_api/apps/account/views.py +++ b/spug_api/apps/account/views.py @@ -150,6 +150,8 @@ def login(request): if not user: user = User.objects.create(username=form.username, nickname=form.username) return handle_user_info(user, x_real_ip) + elif message: + return json_response(error=message) else: if user and user.deleted_by is None: if user.verify_password(form.password): diff --git a/spug_api/libs/ldap.py b/spug_api/libs/ldap.py index 3e748ce..fb1f443 100644 --- a/spug_api/libs/ldap.py +++ b/spug_api/libs/ldap.py @@ -28,6 +28,7 @@ class LDAP: conn.simple_bind_s(result_data[0][0], password) return True, None else: - return False, 'LDAP用户未找到' + return False, None except Exception as error: - return False, '%s' % error + args = error.args + return False, args[0].get('desc', '未知错误') if args else '%s' % error