From 9ee4c85b7c4b8366faae5a84ddf8afe233ff6273 Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 21 Oct 2022 14:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E8=BF=94=E5=9B=9Estatus=E4=BB=A5=E5=8F=8A=E4=B8=87=E8=83=BD?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects_controller.rb | 1 - app/controllers/api/v1/users_controller.rb | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index bc51362ae..810c40171 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -15,6 +15,5 @@ class Api::V1::ProjectsController < Api::V1::BaseController def blame @result_object = Api::V1::Projects::BlameService.call(@project, params[:sha], params[:filepath], current_user&.gitea_token) - puts @result_object end end \ No newline at end of file diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 37a41ff75..ad8e790da 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -16,9 +16,9 @@ class Api::V1::UsersController < Api::V1::BaseController # 60s内不能重复发送 send_email_limit_cache_key = "send_email_60_second_limit:#{mail}" - tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key) + tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key) send_email_control = LimitForbidControl::SendEmailCode.new(mail) - tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? + tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? begin UserMailer.update_email(mail, verification_code).deliver_now @@ -39,17 +39,17 @@ class Api::V1::UsersController < Api::V1::BaseController def check_password password = params[:password] - return render_error("8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD - return render_error("密码错误") unless @observe_user.check_password?(password) + return render_error(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD + return render_error(-5, "密码错误") unless @observe_user.check_password?(password) render_ok end def check_email mail = strip(params[:email]) - return render_error("邮件格式有误") unless mail =~ CustomRegexp::EMAIL + return render_error(-2, "邮件格式有误") unless mail =~ CustomRegexp::EMAIL exist_owner = Owner.find_by(mail: mail) - return render_error('邮箱已被使用') if exist_owner + return render_error(-2, '邮箱已被使用') if exist_owner render_ok end @@ -58,12 +58,13 @@ class Api::V1::UsersController < Api::V1::BaseController mail = strip(params[:email]) code_type = params[:code_type] - return render_error("邮件格式有误") unless mail =~ CustomRegexp::EMAIL + return render_error(-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("验证码不正确") if verifi_code&.code != code - return render_error("验证码已失效") if !verifi_code&.effective? + return render_error(-6, "验证码不正确") if verifi_code&.code != code + return render_error(-6, "验证码已失效") if !verifi_code&.effective? render_ok end