Module: ActiveAuthentication::Controller::Authenticatable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_authentication/controller/authenticatable.rb
Instance Method Summary collapse
- #active_authentication_controller? ⇒ Boolean
- #authenticate_user! ⇒ Object
- #current_user ⇒ Object
- #require_no_authentication ⇒ Object
- #sign_in(user) ⇒ Object
- #sign_out ⇒ Object
- #user_signed_in? ⇒ Boolean
Instance Method Details
#active_authentication_controller? ⇒ Boolean
11 12 13 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 11 def active_authentication_controller? is_a? ::ActiveAuthenticationController end |
#authenticate_user! ⇒ Object
15 16 17 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 15 def authenticate_user! redirect_to new_session_path, alert: t("active_authentication.failure.unauthenticated") unless user_signed_in? end |
#current_user ⇒ Object
19 20 21 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 19 def current_user Current.user ||= user_from_session end |
#require_no_authentication ⇒ Object
23 24 25 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 23 def require_no_authentication redirect_to root_path, alert: t("active_authentication.failure.already_signed_in") if user_signed_in? end |
#sign_in(user) ⇒ Object
27 28 29 30 31 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 27 def sign_in(user) reset_session Current.user = user session[:user_id] = user.id end |
#sign_out ⇒ Object
33 34 35 36 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 33 def sign_out reset_session Current.user = nil end |
#user_signed_in? ⇒ Boolean
38 39 40 |
# File 'lib/active_authentication/controller/authenticatable.rb', line 38 def user_signed_in? current_user.present? end |