fix fork error when exit repo and fix emoj for nickname bug
This commit is contained in:
parent
b4f2d0a9a8
commit
8b1857a3d8
|
@ -36,6 +36,10 @@ class ForksController < ApplicationController
|
|||
render_result(-1, "fork失败,您已拥有了这个项目")
|
||||
elsif @organization && Project.exists?(user_id: [@organization.id], identifier: (params[:new_identifier] || @project.identifier))
|
||||
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
|
||||
# return if current_user != @project.owner
|
||||
# render_result(-1, "自己不能fork自己的项目")
|
||||
|
@ -46,4 +50,9 @@ class ForksController < ApplicationController
|
|||
return if @project.member?(current_user) || current_user.admin?
|
||||
render_forbidden('你没有权限操作')
|
||||
end
|
||||
|
||||
def gitea_check_exit(user)
|
||||
data = Gitea::Repository::GetService.new(user, params[:new_identifier] || @project.identifier)).call
|
||||
data.present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -212,7 +212,8 @@ class UsersController < ApplicationController
|
|||
def update
|
||||
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 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?
|
||||
@user.attributes = user_params.except(:image)
|
||||
unless @user.save
|
||||
|
|
Loading…
Reference in New Issue