ecole_eft_app/app/controllers/application_controller.rb
2013-07-18 01:23:48 +02:00

39 lines
756 B
Ruby

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def auth_admin
if !current_admin
redirect_to new_admin_admin_auth_path
end
end
private
def current_admin
if cookies[:admin_remember_token]
if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
@current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
else
cookies[:admin_remember_token] =nil
end
end
end
helper_method :current_admin
end