Browse Source

解绑时取消激活该用户的所有项目

tags/v3.0.0
moshenglv 5 years ago
parent
commit
cbe5b3afde
3 changed files with 17 additions and 0 deletions
  1. +5
    -0
      app/controllers/ci/base_controller.rb
  2. +6
    -0
      app/controllers/ci/cloud_accounts_controller.rb
  3. +6
    -0
      app/models/ci/repo.rb

+ 5
- 0
app/controllers/ci/base_controller.rb View File

@@ -11,6 +11,11 @@ class Ci::BaseController < ApplicationController
@ci_user, @repo = Ci::Repo.find_with_namespace(namespace, id)
end

def load_all_repo
namespace = current_user.login
@repos = Ci::Repo.find_all_with_namespace(namespace)
end

private
def authorize_access_project!
unless @project.manager?(current_user)


+ 6
- 0
app/controllers/ci/cloud_accounts_controller.rb View File

@@ -5,6 +5,7 @@ class Ci::CloudAccountsController < Ci::BaseController
before_action :load_project, only: %i[create activate]
before_action :authorize_owner!, only: %i[create activate]
before_action :load_repo, only: %i[activate]
before_action :load_all_repo, only: %i[unbind]
before_action :find_cloud_account, only: %i[show oauth_grant]
before_action :validate_params!, only: %i[create bind]
before_action only: %i[create bind] do
@@ -96,6 +97,11 @@ class Ci::CloudAccountsController < Ci::BaseController
def unbind
ActiveRecord::Base.transaction do
unbind_account!
if @repos
@repos.each do |repo|
repo.deactivate!
end
end
render_ok
end
rescue Exception => ex


+ 6
- 0
app/models/ci/repo.rb View File

@@ -14,6 +14,12 @@ class Ci::Repo < Ci::RemoteBase
[user, repo]
end

def self.find_all_with_namespace(namespace_path)
logger.info "########namespace_path: #{namespace_path}"
repos = Ci::Repo.where(repo_namespace: namespace_path)
return repos
end

def activate!(ci_user_id)
update(repo_active: 1,
repo_signer: generate_code,


Loading…
Cancel
Save