Skip to content

Instantly share code, notes, and snippets.

@duard
Created January 11, 2013 17:58
Show Gist options
  • Select an option

  • Save duard/4512689 to your computer and use it in GitHub Desktop.

Select an option

Save duard/4512689 to your computer and use it in GitHub Desktop.
Tem que validar no controler da aplicacao e no de admin ... isso nao é o melhor jeito, mas funfa beleza
#!/bin/env ruby
# encoding: utf-8
class ApplicationController < ActionController::Base
protect_from_forgery
def after_sign_in_path_for(resource)
inicio_path
end
def after_sign_out_path_for(resource)
inicio_path
end
def set_admin_locale
I18n.locale = :"pt-BR"
end
def current_ability
@current_ability ||= Ability.new(current_user)
end
def authenticate_admin_access!
if !current_user.nil?
Rails.logger.info "####################################################################################"
Rails.logger.info "USUARIO LOGADO - #{current_user.email} - #{current_user.role}"
Rails.logger.info "####################################################################################"
if current_user.role == "user"
redirect_to inicio_path
end
else
Rails.logger.info "####################################################################################"
Rails.logger.info "USUARIO NÃO LOGADO USUARIO NÃO LOGADO USUARIO NÃO LOGADO USUARIO NÃO LOGADO USUARIO "
Rails.logger.info "####################################################################################"
redirect_to inicio_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment