fixed fork后重命名项目标识再forked失败

This commit is contained in:
xxq250 2023-08-22 13:47:34 +08:00
parent dd938a218e
commit 56103a885b
1 changed files with 4 additions and 0 deletions

View File

@ -12,6 +12,10 @@ class ForksController < ApplicationController
def authenticate_project!
if current_user&.id == @project.user_id
render_result(-1, "自己不能fork自己的项目")
elsif @project.fork_users.where(user_id: current_user.id).present?
fork = @project.fork_users.find_by(user_id: current_user.id)
render json: { status: 0, id: fork.fork_project_id, identifier: fork.fork_project&.identifier, message: "fork失败你已拥有了这个项目 #{fork.fork_project&.identifier}" }
return
elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier)
render_result(0, "fork失败你已拥有了这个项目")
end