Fix for NCCU 0430 all functions ok with two submanagers but different behavors
This commit is contained in:
1 parent
45e21f9569
commit
05ded8de03
14 files changed
+107
-27
No files matched your search
@@ -2,7 +2,7 @@ class Admin::DashboardsController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
# before_filter :is_admin?
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
@@ -5,7 +5,8 @@ class Admin::DesignsController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :is_admin?
|
||||
before_filter :for_admin_only
|
||||
|
||||
def upload_package
|
||||
if !params[:design].nil?
|
||||
|
||||
@@ -39,9 +39,59 @@ class ApplicationController < ActionController::Base
|
||||
@parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil
|
||||
end
|
||||
|
||||
def auth_failed_in_backend
|
||||
redirect_to admin_dashboards_url
|
||||
end
|
||||
|
||||
# Check if the current_user is admin
|
||||
def is_admin?
|
||||
redirect_to root_url unless current_user.admin?
|
||||
|
||||
auth_failed_in_backend unless current_user.admin?
|
||||
end
|
||||
|
||||
def is_manager?
|
||||
@module_app.managing_users.include?(current_user) || is_admin?
|
||||
end
|
||||
|
||||
def for_admin_only
|
||||
if is_admin?
|
||||
true
|
||||
else
|
||||
flash[:notice] = "Access Denied for you are not Admin"
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_manager
|
||||
if is_manager?
|
||||
true
|
||||
else
|
||||
flash[:notice] = "Access Denied for you are not Manager for this app"
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_sub_manager
|
||||
if (@module_app.sub_managing_users.include?(current_user) || is_manager?)
|
||||
true
|
||||
else
|
||||
flash[:notice] = "Access Denied for you are not SubManager for this app"
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def for_app_user
|
||||
if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager )
|
||||
true
|
||||
else
|
||||
flash[:notice] = "Access Denied for you are not User for this app"
|
||||
auth_failed_in_backend
|
||||
end
|
||||
end
|
||||
|
||||
def check_object_premission(obj,title)
|
||||
flash[:notice] = "Access Denied for you don't have permission for this object"
|
||||
auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? )
|
||||
end
|
||||
|
||||
# Render the page
|
||||
|
||||
Reference in new issue
Block a user