mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
20
app/controllers/forks_controller.rb
Normal file
20
app/controllers/forks_controller.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class ForksController < ApplicationController
|
||||
before_action :require_login, :find_project_with_id
|
||||
before_action :authenticate_project!, :authenticate_user!
|
||||
|
||||
def create
|
||||
@new_project = Projects::ForkService.new(current_user, @project, params[:organization]).call
|
||||
end
|
||||
|
||||
private
|
||||
def authenticate_project!
|
||||
return if current_user != @project.owner
|
||||
render_result(1, "自己不能fork自己的项目")
|
||||
end
|
||||
|
||||
def authenticate_user!
|
||||
return if @project.is_public
|
||||
return if @project.member?(current_user) || current_user.admin?
|
||||
render_forbidden('你没有权限操作')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user