Module: Godmin::Authentication
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/godmin/authentication.rb,
lib/godmin/authentication/user.rb,
lib/godmin/authentication/sessions.rb
Defined Under Namespace
Instance Method Summary collapse
- #admin_user ⇒ Object
- #admin_user_class ⇒ Object
- #admin_user_signed_in? ⇒ Boolean
- #authenticate_admin_user ⇒ Object
Instance Method Details
#admin_user ⇒ Object
25 26 27 28 29 |
# File 'lib/godmin/authentication.rb', line 25 def admin_user if session[:admin_user_id] @admin_user ||= admin_user_class.find_by(id: session[:admin_user_id]) end end |
#admin_user_class ⇒ Object
21 22 23 |
# File 'lib/godmin/authentication.rb', line 21 def admin_user_class raise NotImplementedError, "Must define the admin user class" end |
#admin_user_signed_in? ⇒ Boolean
31 32 33 |
# File 'lib/godmin/authentication.rb', line 31 def admin_user_signed_in? admin_user.present? end |
#authenticate_admin_user ⇒ Object
15 16 17 18 19 |
# File 'lib/godmin/authentication.rb', line 15 def authenticate_admin_user unless admin_user_signed_in? || controller_name == "sessions" redirect_to new_session_path, alert: "Authentication needed" end end |