使用devise重置密码后,将用户重定向到登录页面

时间:2014-12-17 00:33:28

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

我已经在我的Rails 4应用程序中设置了单表继承的设置。我试图让业务用户重置密码后重定向到登录页面。 我正在使用设计post_resetting_password_path_for方法。目前,在用户更新密码后,用户将被注销并重定向到索引页面。

的routes.rb

devise_for :businesses, skip: :sessions, :controllers => {:registrations => "businesses/registrations", :passwords => "businesses/passwords"}

passwords_controller.rb

class Businesses::PasswordsController < Devise::PasswordsController
  protected
    def after_resetting_password_path_for(resource)
      new_user_session_path
    end
end

edit.html.erb

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "sky-form", :id => "sky-form4" }) do |f| %>
    <%= devise_error_messages! %>
    <%= f.password_field :password, :placeholder => "Your new password"  %>
    <%= f.password_field :password_confirmation, :placeholder => "Your new password again"  %>
    <%= f.password_field :current_password, :placeholder => "Your current password"  %>
    <%= f.submit "Save Changes", :class => "btn btn-u" %>
<% end %>

控制台输出

 SQL (0.4ms)  UPDATE "users" SET "encrypted_password" = $1, "updated_at" = $2 WHERE "users"."type" IN ('Business') AND "users"."id" = 7  [["encrypted_password", "$2a$10$5M/ooIQCqUORX7mMS1Xxn.5iRFnwnYvr4Hz.LIpOCKPpi3jPogAlK"], ["updated_at", "2014-12-17 00:32:12.162620"]]
   (1.0ms)  COMMIT
Redirected to http://0.0.0.0:3000/

0 个答案:

没有答案
相关问题