Ruby on rails 轨道4+;设计+;系统更新密码,但未经用户授权并注销

Ruby on rails 轨道4+;设计+;系统更新密码,但未经用户授权并注销,ruby-on-rails,ruby-on-rails-4,devise,Ruby On Rails,Ruby On Rails 4,Devise,在我的Rails项目中,我使用Desive进行身份验证 第一步。使用电子邮件id和密码-系统允许登录 第二步。试图更新密码-密码是由HomeController而不是任何Desive controller编写的 第三步。它允许更新密码。但是,通过发出未经授权的消息,将会话和用户抛出系统 class HomeController < ApplicationController before_filter :authenticate_user! def update_password

在我的Rails项目中,我使用Desive进行身份验证

第一步。使用电子邮件id和密码-系统允许登录

第二步。试图更新密码-密码是由HomeController而不是任何Desive controller编写的

第三步。它允许更新密码。但是,通过发出未经授权的消息,将会话和用户抛出系统

class HomeController < ApplicationController
  before_filter :authenticate_user!
  def update_password
    user = User.find(current_user.id)
    user_save = user.update_attributes(:password => params[:user][:password],
                                        :password_confirmation => params[:user][:password_confirmation])
    if user_save
        redirect_to "/MyProfile", notice: 'User data successfully saved.'
    else
        redirect_to "/MyProfile", notice: 'EROROROOROROROROR.'
    end     
  end
end
class HomeControllerparams[:user][:password],
:password\u confirmation=>params[:user][:password\u confirmation])
如果用户保存
将_重定向到“/MyProfile”,注意:“用户数据已成功保存。”
其他的
将_重定向到“/MyProfile”,注意:'erorororor'
终止
终止
终止
HTML代码:

<form class="navbar-form navbar-left" accept-charset="UTF-8" action="/UpdatePassword" id="CreateUserPassword" method="post">
  <input name="authenticity_token" type="hidden" value="<%= form_authenticity_token.to_s%>">
  <div class="form-group">
    <input type="text" class="form-control" placeholder="Password" name="user[password]">
     <input type="text" class="form-control" placeholder="Password Confirmation" name="user[password_confirmation]">
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

提交

请提供建议…

在重定向之前,您必须再次登录用户

sign_in @user, :bypass => true

请参见“已工作”下的解决方案3。。。有用的链接谢谢