fix object auth. show error message if user try to do object auth in a wrong way.

This commit is contained in:
Fu Matthew committed 2013-01-02 14:34:34 +08:00
1 parent 9937b4ac9b
commit 32c6f17613
7 files changed
+68 -6

No files matched your search

@@ -4,7 +4,6 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
def setting
@sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user
@ob_auth = ObjectAuth.find params[:object_auth_id]
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
@@ -60,6 +59,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
def force_order
authenticate_user!
setup_vars
check_if_user_can_do_object_auth
end
@@ -76,15 +76,25 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
end
def setup_vars
if request.env['HTTP_REFERER'].split('/')[4] == "object_auths"
http_referer = request.env['HTTP_REFERER'] || ''
if http_referer.split('/')[4] == "object_auths"
@app_key = params[:app_key]
else
@app_key = request.env['HTTP_REFERER'].split('/')[4]
@app_key = http_referer.split('/')[4]
end
#@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end")
@app_key.gsub!(/[?].*/,'')
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
if @app_key
@app_key.gsub!(/[?].*/,'')
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
if @module_app.nil?
raise ObjectAuthError, 'Auth procress failed, module_app not exist '
end
else
raise ObjectAuthError, 'Auth procress failed, pls redo your sop'
end
end
end
+5 -1
View File
@@ -2,7 +2,9 @@ class ApplicationController < ActionController::Base
protect_from_forgery
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
include OrbitApp::ErrorHandlers::ObjectAuthErrorHandler
rescue_from ObjectAuthError, :with => :render_object_auth_error
layout :layout_by_resource
helper :admin
@@ -10,6 +12,8 @@ class ApplicationController < ActionController::Base
helper_attr :site_valid_locales
def set_current_user
User.current = current_or_guest_user
end