[英]authentication with mercury-rails
如何通过mercury-rails
gem在Mercury的/editor/.*路由上添加身份验证检查?
我的意思是,我知道你可以:
但是我希望用户被踢出编辑器,因为他/她有一个书签给编辑器但没有登录。
PS:有人可以为此创建一个mercury-editor
标签吗? 否则,搜索水银编辑器几乎是不可能的。
before_filter方法可能就是您想要使用的方法。
您可以添加自己的控制器,而不是从MercuryController继承,并将路由指向您的控制器:
在config / routes.rb中:
...
match '/editor(/*requested_uri)' => "my_mercury#edit", :as => :mercury_editor
Mercury::Engine.routes
...
和app / controllers / my_mercury_controller.rb
class MyMercuryController < MercuryController
before_filter :login_required
def login_required
...
end
end
现在看来,如果你想让他们想要添加一些身份验证代码,那么他们会问你是否会创建
LIB /汞/ authentication.rb
module Mercury
module Authentication
def can_edit?
true # check here to see if the user is logged in/has access
end
end
end
你可以在那里运行你的支票代码。 也许像“if user_signed_in?&& current_user.admin?”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.