auth with ldap

This commit is contained in:
pycook
2020-04-01 20:30:44 +08:00
parent c31be0f753
commit 036e1d236b
6 changed files with 39 additions and 2 deletions

View File

@@ -26,7 +26,10 @@ class LoginView(APIView):
def post(self):
username = request.values.get("username") or request.values.get("email")
password = request.values.get("password")
user, authenticated = User.query.authenticate(username, password)
if current_app.config.get('AUTH_WITH_LDAP'):
user, authenticated = User.query.authenticate_with_ldap(username, password)
else:
user, authenticated = User.query.authenticate(username, password)
if not user:
return abort(403, "User <{0}> does not exist".format(username))
if not authenticated: