Ruby on rails 设计';重置密码';不保存新密码,但允许您登录
所以Deviate的“重置密码”过去在我的应用程序中起作用,但现在它坏了。我在rails 4.1.0上,设计3.2.4。下面是正在发生的事情: 1) 用户单击忘记密码,输入电子邮件,接收电子邮件中的更改密码链接,单击并正确发送到更改密码页面,输入新密码,然后登录 2) 但如果他们注销,他们将无法使用新密码登录 在控制台中,在您更改密码后,加密密码看起来确实会更改。但它没有使用正确的密码进行更新 仅供参考,我在用户注册中有自定义的“新建”和“创建”操作。否则,我在Desive的用户模型中有以下内容:Ruby on rails 设计';重置密码';不保存新密码,但允许您登录,ruby-on-rails,ruby-on-rails-4,devise,passwords,Ruby On Rails,Ruby On Rails 4,Devise,Passwords,所以Deviate的“重置密码”过去在我的应用程序中起作用,但现在它坏了。我在rails 4.1.0上,设计3.2.4。下面是正在发生的事情: 1) 用户单击忘记密码,输入电子邮件,接收电子邮件中的更改密码链接,单击并正确发送到更改密码页面,输入新密码,然后登录 2) 但如果他们注销,他们将无法使用新密码登录 在控制台中,在您更改密码后,加密密码看起来确实会更改。但它没有使用正确的密码进行更新 仅供参考,我在用户注册中有自定义的“新建”和“创建”操作。否则,我在Desive的用户模型中有以下内容
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
devise_for :users, :controllers => {:registrations => "registrations"}
as :user do
post "/users/sign_up" => "registrations#create", :as => :v2_user_registration
end
真是个奇怪的问题,对吧
更新:
下面是应用程序控制器:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
include Pundit
include SessionsHelper
protect_from_forgery with: :exception
before_action :set_user
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def auth_user
if params[:special]
user = User.find_by_special(params[:special])
if user
sign_in user
redirect_to '/files'
end
authenticate_user!
else
authenticate_user!
end
end
def set_user
Gon.global.user = current_user
end
end
class ApplicationController
您能否共享问题中ApplicationController的内容。当然可以。在问题中添加了应用程序控制器。你们都明白了吗?我也有同样的问题(@user2004922不……我从来没有想到这一点。
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
include Pundit
include SessionsHelper
protect_from_forgery with: :exception
before_action :set_user
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
def auth_user
if params[:special]
user = User.find_by_special(params[:special])
if user
sign_in user
redirect_to '/files'
end
authenticate_user!
else
authenticate_user!
end
end
def set_user
Gon.global.user = current_user
end
end