Class: Clearance::DefaultSignInGuard
- Inherits:
-
SignInGuard
- Object
- SignInGuard
- Clearance::DefaultSignInGuard
- Defined in:
- lib/clearance/default_sign_in_guard.rb
Overview
Runs as the base SignInGuard for all requests, regardless of configured Configuration#sign_in_guards.
Instance Attribute Summary
Attributes inherited from SignInGuard
Instance Method Summary collapse
-
#call ⇒ SuccessStatus, FailureStatus
Runs the default sign in guard.
-
#default_failure_message ⇒ String
The default failure message pulled from the i18n framework.
Methods inherited from SignInGuard
#current_user, #failure, #initialize, #next_guard, #signed_in?, #success
Constructor Details
This class inherits a constructor from Clearance::SignInGuard
Instance Method Details
#call ⇒ SuccessStatus, FailureStatus
Runs the default sign in guard.
If there is a value set in the clearance session object, then the guard returns SuccessStatus. Otherwise, it returns FailureStatus with the message returned by #default_failure_message.
12 13 14 15 16 17 18 |
# File 'lib/clearance/default_sign_in_guard.rb', line 12 def call if session.signed_in? success else failure .html_safe end end |
#default_failure_message ⇒ String
The default failure message pulled from the i18n framework.
Will use the value returned from the following i18n keys, in this order:
clearance.controllers.sessions.bad_email_or_password
flashes.failure_after_create
28 29 30 31 32 33 34 |
# File 'lib/clearance/default_sign_in_guard.rb', line 28 def I18n.t( :bad_email_or_password, scope: [:clearance, :controllers, :sessions], default: I18n.t('flashes.failure_after_create').html_safe ) end |