Module: Godmin::Authentication

Extended by:
ActiveSupport::Concern
Defined in:
lib/godmin/authentication.rb,
lib/godmin/authentication/user.rb,
lib/godmin/authentication/sessions_controller.rb

Defined Under Namespace

Modules: SessionsController, User

Instance Method Summary collapse

Instance Method Details

#admin_userObject



24
25
26
27
28
29
# File 'lib/godmin/authentication.rb', line 24

def admin_user
  return unless admin_user_class
  return unless session[:admin_user_id]

  @_admin_user ||= admin_user_class.find_by(id: session[:admin_user_id])
end

#admin_user_classObject



22
# File 'lib/godmin/authentication.rb', line 22

def admin_user_class; end

#admin_user_signed_in?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/godmin/authentication.rb', line 31

def admin_user_signed_in?
  admin_user.present?
end

#authenticateObject



15
16
17
18
19
20
# File 'lib/godmin/authentication.rb', line 15

def authenticate
  return unless authentication_enabled?
  return if admin_user_signed_in?

  redirect_to new_session_path
end