Sha256: 2f28371172769bd295494a870fcd78fb5a3036eba8c8659b995a55f968cf6515

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

module Whodat
  class ApplicationController < ActionController::Base
    protect_from_forgery with: :exception
    include SessionsHelper
    include ApplicationHelper

    def authenticate_user!
      redirect_to new_session_path unless current_user
    end

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

    def sign_out
      session[:user_id] = nil
    end

    private

    def session_cleared?
      user_signed_in? || session[:user_id].nil?
    end

    def cleanup_dead_session
      return unless Whodat::User.find_by( id: session[:user_id] ).nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whodat-1.0.1 app/controllers/whodat/application_controller.rb
whodat-1.0.0 app/controllers/whodat/application_controller.rb