Merge branch 'develop' into standalone_develop

This commit is contained in:
yystopf 2022-05-27 10:48:38 +08:00
commit 2a387ad997
2 changed files with 7 additions and 7 deletions

View File

@ -40,9 +40,9 @@ class Ci::ProjectsController < Ci::BaseController
begin begin
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
if @repo if @repo
@repo.destroy! if @repo&.repo_user_id == 0
return render_error('该项目已经激活') if @repo.repo_active? return render_error('该项目已经激活') if @repo.repo_active?
@repo.activate!(@project) @repo.activate!(@project)
return render_ok
else else
@repo = Ci::Repo.auto_create!(@ci_user, @project) @repo = Ci::Repo.auto_create!(@ci_user, @project)
@ci_user.update_column(:user_syncing, false) @ci_user.update_column(:user_syncing, false)

View File

@ -160,9 +160,9 @@ module Ci::CloudAccountManageable
state = SecureRandom.hex(8) state = SecureRandom.hex(8)
# redirect_uri eg: # redirect_uri eg:
# https://localhost:3000/login/oauth/authorize?client_id=94976481-ad0e-4ed4-9247-7eef106007a2&redirect_uri=http%3A%2F%2F121.69.81.11%3A80%2Flogin&response_type=code&state=9cab990b9cfb1805 # https://localhost:3000/login/oauth/authorize?client_id=94976481-ad0e-4ed4-9247-7eef106007a2&redirect_uri=http%3A%2F%2F121.69.81.11%3A80%2Flogin&response_type=code&state=9cab990b9cfb1805
redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login") # redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login")
clientId = client_id(oauth) # clientId = client_id(oauth)
grant_url = "#{Gitea.gitea_config[:domain]}/login/oauth/authorize?client_id=#{clientId}&redirect_uri=#{redirect_uri}&response_type=code&state=#{state}" grant_url = "#{@cloud_account.drone_url}/login"
logger.info "[gitea] grant_url: #{grant_url}" logger.info "[gitea] grant_url: #{grant_url}"
conn = Faraday.new(url: grant_url) do |req| conn = Faraday.new(url: grant_url) do |req|
@ -179,7 +179,7 @@ module Ci::CloudAccountManageable
def drone_oauth_user!(url, state) def drone_oauth_user!(url, state)
logger.info "[drone] drone_oauth_user url: #{url}" logger.info "[drone] drone_oauth_user url: #{url}"
conn = Faraday.new(url: "#{Gitea.gitea_config[:domain]}#{url}") do |req| conn = Faraday.new(url: url) do |req|
req.request :url_encoded req.request :url_encoded
req.adapter Faraday.default_adapter req.adapter Faraday.default_adapter
req.headers["cookie"] = "_session_=#{SecureRandom.hex(28)}; _oauth_state_=#{state}" req.headers["cookie"] = "_session_=#{SecureRandom.hex(28)}; _oauth_state_=#{state}"
@ -188,8 +188,8 @@ module Ci::CloudAccountManageable
response = conn.get response = conn.get
logger.info "[drone] response headers: #{response.headers}" logger.info "[drone] response headers: #{response.headers}"
true # true
# response.headers['location'].include?('error') ? false : true response.headers['location'].include?('error') ? false : true
end end
private private