From efb4b3040d1c8d49fe5883e779f939f5990b6de1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 25 Mar 2025 15:51:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fixed=20=E5=B7=A5=E4=BD=9C=E9=A1=B9?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E9=A1=B9=E7=9B=AE=E6=97=B6project=5Fissues?= =?UTF-8?q?=5Findex=E9=87=8D=E6=8E=92=E5=BA=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/api/pm/issues/update_service.rb | 4 ++++ app/services/api/v1/issues/update_service.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/api/pm/issues/update_service.rb b/app/services/api/pm/issues/update_service.rb index 21119ca9b..2f1816446 100644 --- a/app/services/api/pm/issues/update_service.rb +++ b/app/services/api/pm/issues/update_service.rb @@ -85,6 +85,10 @@ class Api::Pm::Issues::UpdateService < ApplicationService @updated_issue.root_id = @root_id unless @root_id.nil? #不为 nil的时候更新 @updated_issue.root_id = nil if @root_id.try(:zero?) #为 0 的时候设置为 nil @updated_issue.time_scale = @time_scale unless @time_scale.nil? + if @project_id.present? && @updated_issue.project_id.to_i == 0 + add_project = Project.find_by(id: @project_id) + @updated_issue.project_issues_index = add_project.get_last_project_issues_index + 1 if add_project.present? + end @updated_issue.project_id = @project_id unless @project_id.nil? @updated_issue.updated_on = Time.now @updated_issue.changer_id = @current_user.id diff --git a/app/services/api/v1/issues/update_service.rb b/app/services/api/v1/issues/update_service.rb index 6d2bbedf0..d92513ec5 100644 --- a/app/services/api/v1/issues/update_service.rb +++ b/app/services/api/v1/issues/update_service.rb @@ -85,7 +85,7 @@ class Api::V1::Issues::UpdateService < ApplicationService @updated_issue.root_id = @root_id unless @root_id.nil? #不为 nil的时候更新 @updated_issue.root_id = nil if @root_id.try(:zero?) #为 0 的时候设置为 nil @updated_issue.time_scale = @time_scale unless @time_scale.nil? - if @project_id.present? && @project_id.to_i == 0 + if @project_id.present? && @updated_issue.project_id.to_i == 0 add_project = Project.find_by(id: @project_id) @updated_issue.project_issues_index = add_project.get_last_project_issues_index + 1 if add_project.present? end From 568248e6c1003becbcc07363156c885a1a291b60 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 25 Mar 2025 16:13:06 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fixed=20=E5=B7=A5=E4=BD=9C=E9=A1=B9?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E9=A1=B9=E7=9B=AE=E6=97=B6project=5Fissues?= =?UTF-8?q?=5Findex=E9=87=8D=E6=8E=92=E5=BA=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index b0133eec7..446cb89ac 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -453,7 +453,7 @@ class Project < ApplicationRecord end def get_last_project_issues_index - last_issue = self.issues.issue_issue.last + last_issue = self.issues.issue_issue.order(project_issues_index: :asc).last deleted_issue_count = ($redis_cache.hget("issue_cache_delete_count", self.id) || 0).to_i last_issue&.project_issues_index.present? ? last_issue.project_issues_index + deleted_issue_count : 0 From 076d92a3ebbd730f42b2a70448a4aecedbadf49c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 31 Mar 2025 20:47:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fixed=20=E5=AF=86=E7=A0=81=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E5=85=BC=E5=AE=B9base64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 10 +++++----- app/controllers/api/v1/users_controller.rb | 4 ++-- .../organizations/organizations_controller.rb | 2 +- app/forms/base_form.rb | 6 +++--- app/services/accounts/reset_password_service.rb | 4 ++-- app/services/api/v1/users/update_email_service.rb | 2 +- app/services/api/v1/users/update_phone_service.rb | 2 +- app/services/users/register_service.rb | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 119812225..5e4e22dbd 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -144,7 +144,7 @@ class AccountsController < ApplicationController user = Users::RegisterService.call(register_params) user.mail = "#{user.login}@example.org" if user.mail.blank? - password = decrypt(register_params[:password]) rescue "" + password = decrypt(register_params[:password]) rescue register_params[:password].to_s password = password.strip # gitea用户注册, email, username, password @@ -195,7 +195,7 @@ class AccountsController < ApplicationController # 用户登录 def login - password = decrypt(login_params[:password]) rescue "" + password = decrypt(login_params[:password]) rescue login_params[:password].to_s Users::LoginForm.new(login_params.merge!({password: password})).validate! @user = User.try_to_login(params[:login], password) @@ -225,9 +225,9 @@ class AccountsController < ApplicationController end def change_password - password = decrypt(params[:password]) rescue "" - new_password_repeat = decrypt(params[:new_password_repeat]) rescue "" - old_password = decrypt(params[:old_password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s + new_password_repeat = decrypt(params[:new_password_repeat]) rescue params[:new_password_repeat].to_s + old_password = decrypt(params[:old_password]) rescue params[:old_password] return render_error("两次输入的密码不一致") if password.to_s != new_password_repeat.to_s @user = User.find_by(login: params[:login]) return render_forbidden unless User.current.login == @user&.login diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 676304917..44f74c261 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -54,7 +54,7 @@ class Api::V1::UsersController < Api::V1::BaseController end def check_password - password = decrypt(params[:password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s return tip_exception(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD return tip_exception(-5, "密码错误") unless @observe_user.check_password?(password) render_ok @@ -127,7 +127,7 @@ class Api::V1::UsersController < Api::V1::BaseController def destroy - password = decrypt(params[:password]) rescue "" + password = decrypt(params[:password]) rescue params[:password].to_s return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(password) org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id) org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count diff --git a/app/controllers/organizations/organizations_controller.rb b/app/controllers/organizations/organizations_controller.rb index 6cedea496..f61320638 100644 --- a/app/controllers/organizations/organizations_controller.rb +++ b/app/controllers/organizations/organizations_controller.rb @@ -140,7 +140,7 @@ class Organizations::OrganizationsController < Organizations::BaseController end def password - decrypt(params[:password]) rescue "" + decrypt(params[:password]) rescue params[:password].to_s end def load_organization diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index eb00ec562..0b3969ee8 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -54,14 +54,14 @@ class BaseForm end def check_password(password) - password = decrypt(password) rescue "" + password = decrypt(password) rescue password password = strip(password) raise PasswordFormatError, "密码8~16位密码,支持字母数字和符号" unless password =~ CustomRegexp::PASSWORD end def check_password_confirmation(password, password_confirmation) - password = decrypt(password) rescue "" - password_confirmation = decrypt(password_confirmation) rescue "" + password = decrypt(password) rescue password + password_confirmation = decrypt(password_confirmation) rescue password_confirmation password = strip(password) password_confirmation = strip(password_confirmation) diff --git a/app/services/accounts/reset_password_service.rb b/app/services/accounts/reset_password_service.rb index 58d0fda8b..f05a2fe5c 100644 --- a/app/services/accounts/reset_password_service.rb +++ b/app/services/accounts/reset_password_service.rb @@ -4,8 +4,8 @@ module Accounts # login、code、password、password_confirmation def initialize(user, params) @user = user - @password = decrypt(params[:password]) rescue "" - @password_confirmation = decrypt(params[:password_confirmation]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s + @password_confirmation = decrypt(params[:password_confirmation]) rescue params[:password_confirmation].to_s end def call diff --git a/app/services/api/v1/users/update_email_service.rb b/app/services/api/v1/users/update_email_service.rb index 3f0875d8a..cd7f9b0ef 100644 --- a/app/services/api/v1/users/update_email_service.rb +++ b/app/services/api/v1/users/update_email_service.rb @@ -11,7 +11,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService def initialize(user, params, token =nil) @user = user @token = token - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @mail = params[:email] @old_mail = user.mail @code = params[:code] diff --git a/app/services/api/v1/users/update_phone_service.rb b/app/services/api/v1/users/update_phone_service.rb index b79387773..cb9b12258 100644 --- a/app/services/api/v1/users/update_phone_service.rb +++ b/app/services/api/v1/users/update_phone_service.rb @@ -9,7 +9,7 @@ class Api::V1::Users::UpdatePhoneService < ApplicationService def initialize(user, params) @user = user - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @phone = params[:phone] @code = params[:code] @verify_code = VerificationCode.where(phone: @phone, code_type: 4).last diff --git a/app/services/users/register_service.rb b/app/services/users/register_service.rb index f6c8c2cf2..296a26a02 100644 --- a/app/services/users/register_service.rb +++ b/app/services/users/register_service.rb @@ -4,7 +4,7 @@ class Users::RegisterService < ApplicationService def initialize(params) @login = params[:login] @namespace = params[:namespace] - @password = decrypt(params[:password]) rescue "" + @password = decrypt(params[:password]) rescue params[:password].to_s @code = params[:code] end From e70e8db02dba3de219eb0d27c1e8b0ccbbae4a65 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 1 Apr 2025 11:35:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fixed=20remote=5Fregister=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5e4e22dbd..bbca99f1b 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -32,11 +32,12 @@ class AccountsController < ApplicationController username = params[:username]&.gsub(/\s+/, "") tip_exception("无法使用以下关键词:#{username},请重新命名") if ReversedKeyword.check_exists?(username) email = params[:email]&.gsub(/\s+/, "") + phone = params[:phone]&.gsub(/\s+/, "") password = params[:password] platform = (params[:platform] || 'forge')&.gsub(/\s+/, "") ActiveRecord::Base.transaction do - result = autologin_register(username, email, password, platform) + result = autologin_register(username, email, password, platform, phone) if result[:message].blank? render_ok({user: result[:user]}) else