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