fix: devops organization bug

This commit is contained in:
yystopf 2022-02-10 14:08:14 +08:00
parent 26f87fba16
commit 298abdd1b1
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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]