Sha256: 00eecb4146a431681bdf5b6b974e72c1f0f4e3c22411425be2b5edffe9d9ebe3

Contents?: true

Size: 590 Bytes

Versions: 3

Compression:

Stored size: 590 Bytes

Contents

module AuthManagement
  def sign_in(user)
    session[:user_id] = user.id
  end

  def sign_out
    session[:user_id] = nil
  end

  def signed_in?
    current_user
  end

  def authenticate_user!
    redirect_to new_session_path unless signed_in?
  end

  def authenticate_admin!
    if signed_in?
      redirect_to ::Tramway::Auth.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::Auth.root_path
    else
      redirect_to '/auth/session/new'
    end
  end

  def current_user
    @_current_user ||= ::Tramway::User::User.find_by id: session[:user_id]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tramway-auth-1.1.0.1 app/controllers/concerns/auth_management.rb
tramway-auth-1.1 app/controllers/concerns/auth_management.rb
tramway-auth-1.0.2.1 app/controllers/concerns/auth_management.rb