diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb index 69644e7a5..06e515378 100644 --- a/app/controllers/ci/projects_controller.rb +++ b/app/controllers/ci/projects_controller.rb @@ -40,9 +40,9 @@ class Ci::ProjectsController < Ci::BaseController begin ActiveRecord::Base.transaction do if @repo + @repo.destroy! if @repo&.repo_user_id == 0 return render_error('该项目已经激活') if @repo.repo_active? @repo.activate!(@project) - return render_ok else @repo = Ci::Repo.auto_create!(@ci_user, @project) @ci_user.update_column(:user_syncing, false) diff --git a/app/controllers/concerns/ci/cloud_account_manageable.rb b/app/controllers/concerns/ci/cloud_account_manageable.rb index 9f0998edc..f2157657e 100644 --- a/app/controllers/concerns/ci/cloud_account_manageable.rb +++ b/app/controllers/concerns/ci/cloud_account_manageable.rb @@ -160,9 +160,9 @@ module Ci::CloudAccountManageable state = SecureRandom.hex(8) # 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 - redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login") - 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}" + # redirect_uri = CGI.escape("#{@cloud_account.drone_url}/login") + # clientId = client_id(oauth) + grant_url = "#{@cloud_account.drone_url}/login" logger.info "[gitea] grant_url: #{grant_url}" conn = Faraday.new(url: grant_url) do |req| @@ -179,7 +179,7 @@ module Ci::CloudAccountManageable def drone_oauth_user!(url, state) 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.adapter Faraday.default_adapter req.headers["cookie"] = "_session_=#{SecureRandom.hex(28)}; _oauth_state_=#{state}" @@ -188,8 +188,8 @@ module Ci::CloudAccountManageable response = conn.get logger.info "[drone] response headers: #{response.headers}" - true - # response.headers['location'].include?('error') ? false : true + # true + response.headers['location'].include?('error') ? false : true end private