From cb735a91638fae36e0818c1f8bea964e067058b1 Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Fri, 3 Jan 2020 14:51:12 +0800 Subject: [PATCH 1/2] FIX code review --- app/controllers/application_controller.rb | 12 +++++++++++- app/controllers/repositories_controller.rb | 11 ----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7bc741cf6..aa0b0188f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -328,7 +328,7 @@ class ApplicationController < ActionController::Base def current_user # User.current - User.find_by_id 1 + User.find_by_id 36401 end ## 默认输出json @@ -627,6 +627,16 @@ class ApplicationController < ActionController::Base error.backtrace.each { |msg| Rails.logger.error(msg) } end + def find_user + @user = User.find_by_login params[:login] + render_not_found unless @user + end + + def find_repository + @repo = @user.repositories.find_by_identifier params[:repo_identifier] + render_not_found unless @repo + end + private def object_not_found uid_logger("Missing template or cant't find record, responding with 404") diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b496d06ad..d2624eebe 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -24,17 +24,6 @@ class RepositoriesController < ApplicationController end private - - def find_repository - @repo = @user.repositories.find_by_identifier params[:repo_identifier] - render_not_found unless @repo - end - - def find_user - @user = User.find_by_login params[:login] - render_not_found unless @user - end - def authorizate! if @repo.hidden? && @repo.user != current_user render_forbidden From 2574f72834cdb5bd5e852478bdeeba29de77952a Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Fri, 3 Jan 2020 16:21:25 +0800 Subject: [PATCH 2/2] FIX bug --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 424b75515..293c9a5ff 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -30,7 +30,7 @@ class ProjectsController < ApplicationController end def branches - @branches = Gitea::Repository::BranchesService.new(current_user, @project.identifier).call + @branches = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call end def group_type_list