{"action":"created","issue":{"url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/28","repository_url":"https://api.github.com/repos/tinfoil/devise-two-factor","labels_url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/28/comments","events_url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/28/events","html_url":"https://github.com/tinfoil/devise-two-factor/issues/28","id":72493291,"number":28,"title":"When using lockable, failed_attempts is incremented by two after failed login attempt","user":{"login":"mwalsher","id":3782649,"avatar_url":"https://avatars3.githubusercontent.com/u/3782649?v=4","gravatar_id":"","url":"https://api.github.com/users/mwalsher","html_url":"https://github.com/mwalsher","followers_url":"https://api.github.com/users/mwalsher/followers","following_url":"https://api.github.com/users/mwalsher/following{/other_user}","gists_url":"https://api.github.com/users/mwalsher/gists{/gist_id}","starred_url":"https://api.github.com/users/mwalsher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwalsher/subscriptions","organizations_url":"https://api.github.com/users/mwalsher/orgs","repos_url":"https://api.github.com/users/mwalsher/repos","events_url":"https://api.github.com/users/mwalsher/events{/privacy}","received_events_url":"https://api.github.com/users/mwalsher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2015-05-01T18:34:25Z","updated_at":"2018-03-23T16:30:33Z","closed_at":null,"author_association":"NONE","body":"When using devise-two-factor with devise lockable, there are somehow two calls being made to validate/valid_for_authentication? - the latter of which is doing the failed_attempts increment.\n\nThe first failed_attempts increment happens within this block, and the latter seems to be happening after the authenticate! method is finished executing.\n\n```\nif validate(resource) { !resource.otp_required_for_login ||\n  resource.valid_otp?(params[scope]['otp_attempt']) }\n  super\nend\n```\n\nMy devise initializer is configuring the warden strategy as follows:\n\n```\nconfig.warden do |manager|\n  manager.default_strategies(:scope => :user).unshift :two_factor_authenticatable\nend\n```\n\nMy user model is set up with devise as follows:\n\n```\ndevise :two_factor_authenticatable, :otp_secret_encryption_key => ENV['RSA_KEY_PW'], otp_secret_length: 64\ndevise :registerable, :recoverable, :invitable, :trackable, :timeoutable, :lockable\n```\n"},"comment":{"url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/comments/375723659","html_url":"https://github.com/tinfoil/devise-two-factor/issues/28#issuecomment-375723659","issue_url":"https://api.github.com/repos/tinfoil/devise-two-factor/issues/28","id":375723659,"user":{"login":"dominikdarnel","id":19818645,"avatar_url":"https://avatars0.githubusercontent.com/u/19818645?v=4","gravatar_id":"","url":"https://api.github.com/users/dominikdarnel","html_url":"https://github.com/dominikdarnel","followers_url":"https://api.github.com/users/dominikdarnel/followers","following_url":"https://api.github.com/users/dominikdarnel/following{/other_user}","gists_url":"https://api.github.com/users/dominikdarnel/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikdarnel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikdarnel/subscriptions","organizations_url":"https://api.github.com/users/dominikdarnel/orgs","repos_url":"https://api.github.com/users/dominikdarnel/repos","events_url":"https://api.github.com/users/dominikdarnel/events{/privacy}","received_events_url":"https://api.github.com/users/dominikdarnel/received_events","type":"User","site_admin":false},"created_at":"2018-03-23T16:30:33Z","updated_at":"2018-03-23T16:30:33Z","author_association":"NONE","body":"I have the same problem.\r\nI found that both TwoFactorAuthenticatable#authenticate! and TwoFactorBackupable#authenticate! are run during the authentication workflow. Maybe I am doing something wrong."}}
{"actor":{"display_login":"dominikdarnel"}}