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