|
|
|
@ -685,7 +685,7 @@ class AccountController < ApplicationController
|
|
|
|
|
else
|
|
|
|
|
code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => params[:type].to_i).last
|
|
|
|
|
end
|
|
|
|
|
req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
render :json => req
|
|
|
|
|
end
|
|
|
|
@ -1183,24 +1183,31 @@ class AccountController < ApplicationController
|
|
|
|
|
def reset_psd
|
|
|
|
|
if params[:lost_psd_phone] && params[:lost_psd_phone].strip != ""
|
|
|
|
|
@user = User.where("phone = '#{params[:lost_psd_phone].to_s}'").first
|
|
|
|
|
code = VerificationCode.where(:phone => params[:lost_psd_phone], :code => params[:code], :code_type => 2).last
|
|
|
|
|
|
|
|
|
|
elsif params[:lost_psd_email] && params[:lost_psd_email].strip != ""
|
|
|
|
|
@user = User.where("mail = '#{params[:lost_psd_email].to_s}'").first
|
|
|
|
|
code = VerificationCode.where(:email => params[:lost_psd_email], :code => params[:code], :code_type => 3).last
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @user.present?
|
|
|
|
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
|
|
|
|
if @user.save
|
|
|
|
|
Token.where(:user_id => @user, :action => "recovery").destroy_all
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
if !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60
|
|
|
|
|
if @user.present?
|
|
|
|
|
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
|
|
|
|
|
if @user.save
|
|
|
|
|
Token.where(:user_id => @user, :action => "recovery").destroy_all
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
return
|
|
|
|
|
@status = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|