FIX ucloud account bug

This commit is contained in:
Jasder 2020-07-15 10:22:41 +08:00
parent f358361b89
commit 123e8d7659
1 changed files with 10 additions and 1 deletions

View File

@ -13,7 +13,16 @@ class DevOps::CloudAccountsController < ApplicationController
create_params = devops_params.merge(ip_num: IPAddr.new(devops_params[:ip_num]).to_i, secret: DevOps::CloudAccount.encrypted_secret(devops_params[:secret]))
logger.info "######### create_params: #{create_params}"
return if @project.dev_ops_cloud_account
if cloud_account = @project.dev_ops_cloud_account
cloud_account
else
cloud_account = DevOps::CloudAccount.new(create_params)
cloud_account.user = current_user
cloud_account.project_id = @project.id
cloud_account.save!
end
# 2. 生成oauth2应用程序的client_id和client_secrete
gitea_oauth = Gitea::Oauth2::CreateService.call(current_user.gitea_token, {name: "pipeline", redirect_uris: ["#{cloud_account.drone_url}/login"]})