|
|
|
@ -31,10 +31,11 @@ class AccountsController < ApplicationController
|
|
|
|
|
verifi_code = VerificationCode.where(email: email, code: code, code_type: 8).last
|
|
|
|
|
end
|
|
|
|
|
uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}")
|
|
|
|
|
check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
|
|
|
|
|
# todo 上线前请删除
|
|
|
|
|
if !check_code && code != "513231"
|
|
|
|
|
tip_exception("验证码无效")
|
|
|
|
|
# check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
|
|
|
|
|
# todo 上线前请删除万能验证码"513231"
|
|
|
|
|
if code != "513231"
|
|
|
|
|
tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip
|
|
|
|
|
tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
code = generate_identifier User, 8
|
|
|
|
@ -56,6 +57,7 @@ class AccountsController < ApplicationController
|
|
|
|
|
)
|
|
|
|
|
successful_authentication(@user)
|
|
|
|
|
session[:user_id] = @user.id
|
|
|
|
|
normal_status("注册成功")
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
@ -88,10 +90,8 @@ class AccountsController < ApplicationController
|
|
|
|
|
verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last
|
|
|
|
|
user = User.find_by_mail(email) #这里有问题,应该是为email,而不是mail 6.13-hs
|
|
|
|
|
end
|
|
|
|
|
check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
|
|
|
|
|
unless check_code
|
|
|
|
|
tip_exception("验证码无效")
|
|
|
|
|
end
|
|
|
|
|
tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip
|
|
|
|
|
tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60
|
|
|
|
|
|
|
|
|
|
user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
|
|
|
|
if user.save!
|
|
|
|
|