Module: UffizziCore::AuthManagement
- Included in:
- ApplicationController
- Defined in:
- app/controllers/concerns/uffizzi_core/auth_management.rb
Instance Method Summary collapse
- #authenticate_request! ⇒ Object
- #current_user ⇒ Object
- #sign_in(user) ⇒ Object
- #sign_out ⇒ Object
- #signed_in? ⇒ Boolean
Instance Method Details
#authenticate_request! ⇒ Object
20 21 22 |
# File 'app/controllers/concerns/uffizzi_core/auth_management.rb', line 20 def authenticate_request! current_user ? true : head(:unauthorized) end |
#current_user ⇒ Object
16 17 18 |
# File 'app/controllers/concerns/uffizzi_core/auth_management.rb', line 16 def current_user @current_user ||= UffizziCore::User.find_by(id: session[:user_id]) end |
#sign_in(user) ⇒ Object
4 5 6 |
# File 'app/controllers/concerns/uffizzi_core/auth_management.rb', line 4 def sign_in(user) session[:user_id] = user.id end |
#sign_out ⇒ Object
8 9 10 |
# File 'app/controllers/concerns/uffizzi_core/auth_management.rb', line 8 def sign_out session[:user_id] = @current_user = nil end |
#signed_in? ⇒ Boolean
12 13 14 |
# File 'app/controllers/concerns/uffizzi_core/auth_management.rb', line 12 def signed_in? session[:user_id].present? && current_user.present? end |