From 2081ce11de6ac1fd5772cce2df4d018508951524 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Mon, 13 Apr 2020 12:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9fork=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forks_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/forks_controller.rb b/app/controllers/forks_controller.rb index df0b74bc2..93772cd19 100644 --- a/app/controllers/forks_controller.rb +++ b/app/controllers/forks_controller.rb @@ -8,8 +8,13 @@ class ForksController < ApplicationController private def authenticate_project! - return if current_user != @project.owner - render_result(-1, "自己不能fork自己的项目") + if current_user&.id == @project.user_id + render_result(-1, "自己不能fork自己的项目") + elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier) + render_result(-1, "fork失败,你已拥有了这个项目") + end + # return if current_user != @project.owner + # render_result(-1, "自己不能fork自己的项目") end def authenticate_user!