Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a block to be passed to authenticate #704

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Yield user with the error message once we have one
Signed-off-by: Steven Hoffman <[email protected]>
  • Loading branch information
Fustrate committed Jul 20, 2015
commit d2778314169a1dbd24784f33f9de6ad262477046
6 changes: 4 additions & 2 deletions lib/sorcery/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ def authenticate(*credentials, &block)
@sorcery_config.before_authenticate.each do |callback|
success, reason = user.send(callback)

return authentication_response(failure: reason, &block) unless success
unless success
return authentication_response(user: user, failure: reason, &block)
end
end

unless user.valid_password?(credentials[1])
return authentication_response(failure: :invalid_password, &block)
return authentication_response(user: user, failure: :invalid_password, &block)
end

authentication_response(user: user, return_value: user, &block)
Expand Down