【问题标题】:Custom authenticate_user! devise method in rails自定义身份验证用户!在rails中设计方法
【发布时间】:2015-05-28 21:43:08
【问题描述】:

我的用户模型上有一个布尔属性“boss”,如何在我的 before_filter 中创建自定义 authenticate_user!,以便只有 user.boss == true 的用户通过身份验证?

【问题讨论】:

标签: ruby-on-rails authentication ruby-on-rails-4 devise


【解决方案1】:
before_filter do 
    redirect_to root_path unless current_user && current_user.boss?
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 2015-04-09
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多