#encoding: utf-8
module LoginHelper

  def do_sudo(user, old)
    session[:user] = user.id
    session[:sudo_user] = old.id
  end

  def log_in(user)
    session.delete(:sudo_user)
    session[:user] = user.id
  end

  def current_user
    @current_user ||= User.find_by(id: session[:user])
  end

end
