fix fork error when exit repo and fix emoj for nickname bug

This commit is contained in:
呱呱呱 2023-07-13 10:56:44 +08:00
parent b4f2d0a9a8
commit 8b1857a3d8
2 changed files with 11 additions and 1 deletions

View File

@ -36,6 +36,10 @@ class ForksController < ApplicationController
render_result(-1, "fork失败您已拥有了这个项目") render_result(-1, "fork失败您已拥有了这个项目")
elsif @organization && Project.exists?(user_id: [@organization.id], identifier: (params[:new_identifier] || @project.identifier)) elsif @organization && Project.exists?(user_id: [@organization.id], identifier: (params[:new_identifier] || @project.identifier))
render_result(-1, "fork失败组织已拥有了这个项目") render_result(-1, "fork失败组织已拥有了这个项目")
elsif gitea_check_exit(current_user)
render_result(-1, "fork失败仓库底层数据出现了问题")
elsif @organization && gitea_check_exit(@organization)
render_result(-1, "fork失败fork失败仓库底层数据出现了问题")
end end
# return if current_user != @project.owner # return if current_user != @project.owner
# render_result(-1, "自己不能fork自己的项目") # render_result(-1, "自己不能fork自己的项目")
@ -46,4 +50,9 @@ class ForksController < ApplicationController
return if @project.member?(current_user) || current_user.admin? return if @project.member?(current_user) || current_user.admin?
render_forbidden('你没有权限操作') render_forbidden('你没有权限操作')
end end
def gitea_check_exit(user)
data = Gitea::Repository::GetService.new(user, params[:new_identifier] || @project.identifier)).call
data.present?
end
end end

View File

@ -212,7 +212,8 @@ class UsersController < ApplicationController
def update def update
return render_not_found unless @user = User.find_by(login: params[:id]) || User.find_by_id(params[:id]) return render_not_found unless @user = User.find_by(login: params[:id]) || User.find_by_id(params[:id])
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id) return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
return normal_status(-1, "昵称无法使用以下关键词:#{user_params[:nickname]},请重新命名") if ReversedKeyword.check_exists?(user_params[:nickname]) keywords = user_params[:nickname].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
return normal_status(-1, "昵称中包含关键词:#{keywords},请重新命名") if ReversedKeyword.check_exists?(keywords)
Util.write_file(@image, avatar_path(@user)) if user_params[:image].present? Util.write_file(@image, avatar_path(@user)) if user_params[:image].present?
@user.attributes = user_params.except(:image) @user.attributes = user_params.except(:image)
unless @user.save unless @user.save