跳过设计控制器中特定操作的身份验证和授权

时间:2017-10-19 14:27:32

标签: ruby-on-rails ruby authentication devise

我一直在开发一个系统,用户需要使用电子邮件验证帐户,但当用户点击链接验证激活他的帐户时,系统会显示登录页面。如果用户的帐户尚未处于活动状态,用户可以如何登录。我只需要跳过对该特定操作的身份验证,授权,其中"帐户处于活动状态"功能是写的。

我用过

skip_before_action :authenticate_user!, :only => :active_account 

但它不起作用。请帮助我。

由于

日志

Started GET "/admins/active_account/6beoG6zUYLdY9uiohITPFw" for 10.0.2.2 at 2017-10-19 14:46:37 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:ApplicationController> at /vagrant/donation-simple/app/controllers/application_controller.rb:4)
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:AdminsController> at /vagrant/donation-simple/app/controllers/admins_controller.rb:4)
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:AdminsController> at /vagrant/donation-simple/app/controllers/admins_controller.rb:11)
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <class:AdminsController> at /vagrant/donation-simple/app/controllers/admins_controller.rb:14)
Processing by AdminsController#active_account as HTML
  Parameters: {"token"=>"6beoG6zUYLdY9uiohITPFw"}
Completed 401 Unauthorized in 16ms (ActiveRecord: 0.0ms)


Started GET "/users/sign_in" for 10.0.2.2 at 2017-10-19 14:46:37 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::SessionsController#new as HTML
  Rendering users/sessions/new.html.erb within layouts/admin
  Rendered users/sessions/new.html.erb within layouts/admin (2.7ms)
Completed 200 OK in 362ms (Views: 331.8ms | ActiveRecord: 5.2ms)

0 个答案:

没有答案