From 298abdd1b1c6400c26b07f989ace341df5331945 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 10 Feb 2022 14:08:14 +0800 Subject: [PATCH] fix: devops organization bug --- app/controllers/ci/base_controller.rb | 2 +- app/controllers/ci/secrets_controller.rb | 2 +- app/models/ci/repo.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/ci/base_controller.rb b/app/controllers/ci/base_controller.rb index 1649721cd..f4c64e90a 100644 --- a/app/controllers/ci/base_controller.rb +++ b/app/controllers/ci/base_controller.rb @@ -8,7 +8,7 @@ class Ci::BaseController < ApplicationController namespace = params[:owner] id = params[:repo] || params[:id] - @ci_user, @repo = Ci::Repo.find_with_namespace(namespace, id) + @ci_user, @repo = Ci::Repo.find_with_namespace(namespace, id, current_user.login) end def load_all_repo diff --git a/app/controllers/ci/secrets_controller.rb b/app/controllers/ci/secrets_controller.rb index 698e7bbe0..324f0bb53 100644 --- a/app/controllers/ci/secrets_controller.rb +++ b/app/controllers/ci/secrets_controller.rb @@ -46,7 +46,7 @@ class Ci::SecretsController < Ci::BaseController end def ci_drone_url - user = User.find_by(login: params[:owner]) + user = User.find_by(login: params[:owner]) || User.find_by(login: current_user.login) user&.ci_cloud_account.drone_url end diff --git a/app/models/ci/repo.rb b/app/models/ci/repo.rb index 6c2a6d744..871310df6 100644 --- a/app/models/ci/repo.rb +++ b/app/models/ci/repo.rb @@ -5,10 +5,10 @@ class Ci::Repo < Ci::RemoteBase has_one :perm, foreign_key: :perm_repo_uid has_many :builds, foreign_key: :build_repo_id, dependent: :destroy - def self.find_with_namespace(namespace_path, identifier) + def self.find_with_namespace(namespace_path, identifier, user_login) logger.info "########namespace_path: #{namespace_path} ########identifier: #{identifier} " - - user = Ci::User.find_by_user_login namespace_path + user_login = user_login || namespace_path + user = Ci::User.find_by_user_login user_login repo = Ci::Repo.where(repo_namespace: namespace_path, repo_name: identifier).first [user, repo]