Sha256: 99ab964d068f05e6506dd91364b001fec5782f14a3081336efffd5b180329f9a

Contents?: true

Size: 590 Bytes

Versions: 18

Compression:

Stored size: 590 Bytes

Contents

module AuthManagment
  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::User.root_path if !current_user.admin? && request.env['PATH_INFO'] != ::Tramway::User.root_path
    else
      redirect_to '/users/session/new'
    end
  end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tramway-user-1.1.8 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.7 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.6 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.5 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.4.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.4 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.3 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.2 app/controllers/concerns/auth_managment.rb
tramway-user-1.1.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.5 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.4 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.3.3 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.3.2 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.3.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.3 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.2.3 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.2.2 app/controllers/concerns/auth_managment.rb