Module: UffizziCore::AuthManagement

Included in:
ApplicationController
Defined in:
app/controllers/concerns/uffizzi_core/auth_management.rb

Instance Method Summary collapse

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_userObject



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 (user)
  session[:user_id] = user.id
end

#sign_outObject



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

Returns:

  • (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