Skip to content

Commit

Permalink
remove duplication of verify_num_successful_logins code (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
edulix committed Dec 4, 2021
1 parent e57de77 commit b69724f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions authapi/authmethods/m_emailpwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,12 @@ def authenticate(self, auth_event, request, mode='authenticate'):
return self.authenticate_error("invalid-pipeline", req, auth_event)

if mode == "authenticate":
if not verify_num_successful_logins(auth_event, 'OpenIdConnect', user, req):
if not verify_num_successful_logins(
auth_event, 'EmailPWD', user, req
):
return self.authenticate_error(
"invalid_num_successful_logins_allowed", req, auth_event
)
if (auth_event.num_successful_logins_allowed > 0 and
user.userdata.successful_logins.filter(is_active=True).count() >= auth_event.num_successful_logins_allowed):
return self.authenticate_error(
"invalid_num_successful_logins_allowed", req, auth_event)

return return_auth_data('PWD', req, request, user, auth_event)

LOGGER.debug(\
Expand Down

0 comments on commit b69724f

Please sign in to comment.