| @@ -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) | |||
| @@ -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 | |||
| @@ -849,4 +849,36 @@ await octokit.request('POST /api/:owner/:repo/applied_transfer_projects/cancel.j | |||
| "created_at": "2021-04-26 09:54", | |||
| "time_ago": "1分钟前" | |||
| } | |||
| ``` | |||
| ## 退出项目 | |||
| 供项目成员(开发者、报告者)退出项目用 | |||
| > 示例: | |||
| ```shell | |||
| curl -X POST http://localhost:3000/api/ceshi1/ceshi_repo1/quit.json | |||
| ``` | |||
| ```javascript | |||
| await octokit.request('POST /api/:owner/:repo/quit.json') | |||
| ``` | |||
| ### HTTP 请求 | |||
| `POST /api/:owner/:repo/quit.json` | |||
| ### 请求参数 | |||
| 参数 | 必选 | 默认 | 类型 | 字段说明 | |||
| --------- | ------- | ------- | -------- | ---------- | |||
| |owner |是| |string |用户登录名 | | |||
| |repo |是| |string |项目标识identifier | | |||
| > 返回的JSON示例: | |||
| ```json | |||
| { | |||
| "status": 0, | |||
| "message": "success" | |||
| } | |||
| ``` | |||
| @@ -467,6 +467,9 @@ | |||
| <li> | |||
| <a href="#4f8579f6bd" class="toc-h2 toc-link" data-title="取消迁移项目">取消迁移项目</a> | |||
| </li> | |||
| <li> | |||
| <a href="#88c0b2e25f" class="toc-h2 toc-link" data-title="退出项目">退出项目</a> | |||
| </li> | |||
| </ul> | |||
| </li> | |||
| <li> | |||
| @@ -6046,6 +6049,49 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat | |||
| </span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-04-26 09:54"</span><span class="p">,</span><span class="w"> | |||
| </span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1分钟前"</span><span class="w"> | |||
| </span><span class="p">}</span><span class="w"> | |||
| </span></code></pre></div><h2 id='88c0b2e25f'>退出项目</h2> | |||
| <p>供项目成员(开发者、报告者)退出项目用</p> | |||
| <blockquote> | |||
| <p>示例:</p> | |||
| </blockquote> | |||
| <div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/ceshi1/ceshi_repo1/quit.json | |||
| </code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/:owner/:repo/quit.json</span><span class="dl">'</span><span class="p">)</span> | |||
| </code></pre></div><h3 id='http-15'>HTTP 请求</h3> | |||
| <p><code>POST /api/:owner/:repo/quit.json</code></p> | |||
| <h3 id='1f9ac54b15-13'>请求参数</h3> | |||
| <table><thead> | |||
| <tr> | |||
| <th>参数</th> | |||
| <th>必选</th> | |||
| <th>默认</th> | |||
| <th>类型</th> | |||
| <th>字段说明</th> | |||
| </tr> | |||
| </thead><tbody> | |||
| <tr> | |||
| <td>owner</td> | |||
| <td>是</td> | |||
| <td></td> | |||
| <td>string</td> | |||
| <td>用户登录名</td> | |||
| </tr> | |||
| <tr> | |||
| <td>repo</td> | |||
| <td>是</td> | |||
| <td></td> | |||
| <td>string</td> | |||
| <td>项目标识identifier</td> | |||
| </tr> | |||
| </tbody></table> | |||
| <blockquote> | |||
| <p>返回的JSON示例:</p> | |||
| </blockquote> | |||
| <div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w"> | |||
| </span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> | |||
| </span><span class="nl">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"success"</span><span class="w"> | |||
| </span><span class="p">}</span><span class="w"> | |||
| </span></code></pre></div><h1 id='repositories'>Repositories</h1><h2 id='0a366f0c25'>仓库详情</h2> | |||
| <p>仓库详情</p> | |||