Authlogic 针对特定情况关闭 require_password_confirmation [英] Authlogic turn off require_password_confirmation for a certain case
问题描述
我有一个使用 authlogic 登录机制的应用.
I have an app that uses authlogic for login mechanism.
我的注册页面不需要密码确认,但密码重置页面需要.
My sign up page requires no password confirmation but password reset page does.
acts_as_authentic do |a|
a.require_password_confirmation = true
end
上面的代码为所有操作启用密码确认,但在我的情况下不需要.它应该在调用密码重置时打开,在用户注册时关闭.
The above code turns on password confirmation for all the actions but which is not required in my case. It should be turned on when password reset is called and off when user signs up.
有没有办法有条件地打开和关闭它?
Is there a way to turn this on and off on a conditional basis ?
谢谢
推荐答案
将密码确认设置为 false.
Set password confirmation to false.
acts_as_authentic do |a|
a.require_password_confirmation = false
end
在UsersController
的create
操作中设置password_confirmation
值.
Set the password_confirmation
value in the create
action of UsersController
.
before_action :set_password_confirmation, :only => :create
def set_password_confirmation
if params[:user]
params[:user][:password_confirmation] = params[:user][:password]
end
end
这篇关于Authlogic 针对特定情况关闭 require_password_confirmation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!