acl9和设计似乎并不能很好地协同工作

时间:2010-06-12 23:06:51

标签: ruby-on-rails authentication authorization devise acl9

我有一个用户模型,其访问权限由ACL9控制。

UsersController中的

#ACL9 related stuff
before_filter :load_user, :only => [:show]
  access_control do
    allow :owner, :of => :user, :to => [:show]
  end

def load_user
  user = User.find(params[:id])
end
ApplicationController中的

rescue_from 'Acl9::AccessDenied', :with => :access_denied

def access_denied
  authenticate_user! # a method from Devise
end

在登录页面http://localhost:3000/users/sign_in中输入网址是没有问题的,但是当我首先输入用户页面时,这是一个问题,我希望将其重定向到自动登录页面通过上面的逻辑。

http://localhost:3000/users/1 =>无限重定向地狱。它会尝试再次重定向回users/1,而不是直接转到users/sign_in

有没有人对可能出现的问题有意见?

1 个答案:

答案 0 :(得分:0)

我认为你不应该在Devise用户控制器中使用Acl9。由于您未经过身份验证,因此您没有权利,也无法进行身份验证:D。 您可能希望禁止用户删除,因此它应该是:

access_control :only => [:destroy] do
      allow :admin
end

对于UsersController,如果要将其保留在应用程序控制器中,则应覆盖access_control。