forked from Gitlink/forgeplus
解绑时取消激活该用户的所有项目
This commit is contained in:
parent
f7a5157788
commit
cbe5b3afde
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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…
Reference in New Issue