【问题标题】:acl9 and devise don't seem to work well togetheracl9 和 devise 似乎不能很好地协同工作
【发布时间】:2010-06-12 23:06:51
【问题描述】:

我有一个用户模型,其访问由 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的url是没有问题的,但是当我首先输入用户页面时就会出现问题,我希望它会被重定向到通过自动登录页面上面的逻辑。

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

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

【问题讨论】:

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


    【解决方案1】:

    我认为你不应该在设计用户控制器中使用 Acl9。由于您没有经过身份验证,因此您没有任何权利,也不会进行身份验证:D。 你可能想禁止用户删除,所以应该是这样的:

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

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

    【讨论】:

      猜你喜欢
      • 2016-12-08
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-14
      • 2018-01-18
      • 1970-01-01
      • 2018-12-25
      相关资源
      最近更新 更多