Allow override of user authentication logic for API

This commit is contained in:
Lance Edgar 2019-11-26 15:28:03 -06:00
parent 8cbabfbb95
commit 31ae68f96e

View file

@ -82,13 +82,16 @@ class AuthenticationView(APIView):
if not (username and password): if not (username and password):
return {'error': "Invalid username or password"} return {'error': "Invalid username or password"}
user = authenticate_user(Session(), username, password) user = self.authenticate_user(username, password)
if not user: if not user:
return {'error': "Invalid username or password"} return {'error': "Invalid username or password"}
login_user(self.request, user) login_user(self.request, user)
return self.user_info(user) return self.user_info(user)
def authenticate_user(self, username, password):
return authenticate_user(Session(), username, password)
@api @api
def logout(self): def logout(self):
""" """