Added helper is_role().
This commit is contained in:
parent
4f02fb1f7d
commit
9ec70b1a0e
1 changed files with 9 additions and 1 deletions
|
@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
|
|||
include UserInfo
|
||||
# http_basic_authenticate_with :name => "test", :password => "ttt"
|
||||
|
||||
helper_method :current_user, :authentication_check, :config_frontend, :user_data_full
|
||||
helper_method :current_user, :authentication_check, :config_frontend, :user_data_full, :is_role
|
||||
|
||||
before_filter :set_user
|
||||
before_filter :cors_preflight_check
|
||||
|
@ -127,6 +127,14 @@ class ApplicationController < ActionController::Base
|
|||
UserInfo.current_user_id = current_user.id
|
||||
end
|
||||
|
||||
def is_role( role_name )
|
||||
return false if !current_user
|
||||
current_user.roles.each { |role|
|
||||
return true if role.name == role_name
|
||||
}
|
||||
return false
|
||||
end
|
||||
|
||||
def log_view (object)
|
||||
history_type = History::Type.where( :name => 'viewed' ).first
|
||||
if !history_type || !history_type.id
|
||||
|
|
Loading…
Reference in a new issue