Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop
This commit is contained in:
commit
2945570a51
|
@ -39,17 +39,17 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
|
||||
def check_password
|
||||
password = params[:password]
|
||||
return render_error(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
|
||||
return render_error(-5, "密码错误") unless @observe_user.check_password?(password)
|
||||
return tip_exception(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
|
||||
return tip_exception(-5, "密码错误") unless @observe_user.check_password?(password)
|
||||
render_ok
|
||||
end
|
||||
|
||||
def check_email
|
||||
mail = strip(params[:email])
|
||||
return render_error(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
return tip_exception(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
|
||||
exist_owner = Owner.find_by(mail: mail)
|
||||
return render_error(-2, '邮箱已被使用') if exist_owner
|
||||
return tip_exception(-2, '邮箱已被使用') if exist_owner
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
@ -58,13 +58,13 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
mail = strip(params[:email])
|
||||
code_type = params[:code_type]
|
||||
|
||||
return render_error(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
return tip_exception(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL
|
||||
|
||||
verifi_code = VerificationCode.where(email: mail, code: code, code_type: code_type).last
|
||||
return render_ok if code == "123123" && EduSetting.get("code_debug") # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
|
||||
return render_error(-6, "验证码不正确") if verifi_code&.code != code
|
||||
return render_error(-6, "验证码已失效") if !verifi_code&.effective?
|
||||
return tip_exception(-6, "验证码不正确") if verifi_code&.code != code
|
||||
return tip_exception(-6, "验证码已失效") if !verifi_code&.effective?
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
|
|
@ -20,12 +20,13 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
|
|||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
raise Error, "密码不正确." unless @user.check_password?(@password)
|
||||
if !(@verify_code == "123123" && EduSetting.get("code_debug")) # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
raise Error, "验证码不正确." if @verify_code&.code != @code
|
||||
raise Error, "验证码已失效." if !@verify_code&.effective?
|
||||
end
|
||||
exist_owner = Owner.find_by(mail: @mail)
|
||||
raise Error, "邮箱已被使用." if exist_owner
|
||||
is_debug = @code == "123123" && EduSetting.get("code_debug") # 万能验证码,用于测试 # TODO 万能验证码,用于测试
|
||||
raise Error, "验证码不正确." if @verify_code&.code != @code && !is_debug
|
||||
raise Error, "验证码已失效." if !@verify_code&.effective? && !is_debug
|
||||
|
||||
# begin
|
||||
begin
|
||||
ActiveRecord::Base.transaction do
|
||||
change_user_email
|
||||
excute_data_to_gitea
|
||||
|
@ -34,15 +35,15 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
|
|||
|
||||
return gitea_data
|
||||
|
||||
# rescue
|
||||
# raise Error, "服务器错误,请联系系统管理员!"
|
||||
# end
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
access_token: @user.gitea_token
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue