Sha256: 324d3faae25fef6f0646b2db2439b156efeda3ffec724d302cffb46287a5e884

Contents?: true

Size: 514 Bytes

Versions: 18

Compression:

Stored size: 514 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 '/' unless current_user.admin?
    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.0.2.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.2 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.14 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.13 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.12 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.11 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.10 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.9 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.8 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.7 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.6 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.5 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.4 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.3 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.2 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.0.1 app/controllers/concerns/auth_managment.rb
tramway-user-1.0 app/controllers/concerns/auth_managment.rb