Repository navigation
Frontend API login: honour the login lockout - #1101
Merged
Merged
Conversation
The frontend API token login checked the password through LoginCustomer only. It did not look at CannotLoginUntilDateUtc and did not report a wrong password, so with lockout turned on a locked-out account still signed in there and wrong passwords there were never counted. The validator now refuses a locked-out or deleted account before the password check, raises CustomerLoginFailedEvent on a wrong password as the storefront login does, and treats a password that is not base64 as a failed login instead of an error.
…username when usernames are on Wrong passwords on the API login now count towards the lockout, but a successful API login never cleared them, so an app user who mistyped now and then was locked out in the end. A successful login now resets the failed attempts and stamps the last login date, as the login page does, without the cart merge the login page's event also runs. With usernames enabled, LoginCustomer looks the customer up by username, so the e-mail the API passed found nobody and the login failed with an error. The validator now passes the username of the customer it found by e-mail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The frontend API token login (
/TokenWeb/Login,LoginWebValidator) checked the password throughLoginCustomeronly. Unlike the storefrontLoginValidatorit did not look atCannotLoginUntilDateUtcand did not raiseCustomerLoginFailedEvent. With lockout turned on (FailedPasswordAllowedAttempts> 0), a locked-out account still got a token there, and wrong passwords tried there were never counted.Changes
LoginWebValidator:CustomerLoginFailedEventwhenLoginCustomerreports a wrong password, so these attempts count towards the lockoutFormatException(500)Notes
FailedPasswordAllowedAttempts = 0); whether to turn it on for new installations is a separate decision.Tests
LoginWebValidatorTests: locked-out account fails without a password check, wrong password raises the event, non-base64 password fails.Grand.Module.Api.Tests(113) pass.Review follow-up
FailedLoginAttemptsandCannotLoginUntilDateUtcand stampsLastLoginDateUtc(UpdateCustomerLastLoginDate), as the login page does, so occasional typos no longer add up to a lockout.CustomerLoggedInEventis not published: its cart merge needs a guest the API login does not have.UsernamesEnabled,LoginCustomerlooks the customer up by username; the validator now passes the username of the customer it found by e-mail instead of the e-mail, which found nobody and failed with an error.LoginWebValidatorTests: both cases.Grand.Module.Api.Tests(115) pass.