From bd16ca476d8d84e868b778c2a0f0f9a95dbe8a10 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 26 May 2022 15:08:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0:=20=E9=80=80=E5=87=BA?= =?UTF-8?q?=E4=BB=93=E5=BA=93api=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/docs/slate/source/includes/_projects.md | 32 ++++++++++++++ public/docs/api.html | 46 +++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/app/docs/slate/source/includes/_projects.md b/app/docs/slate/source/includes/_projects.md index d4899a710..e133bcdda 100644 --- a/app/docs/slate/source/includes/_projects.md +++ b/app/docs/slate/source/includes/_projects.md @@ -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" +} ``` \ No newline at end of file diff --git a/public/docs/api.html b/public/docs/api.html index 45da64400..8ef6924b9 100644 --- a/public/docs/api.html +++ b/public/docs/api.html @@ -467,6 +467,9 @@
  • 取消迁移项目
  • +
  • + 退出项目 +
  • @@ -6026,6 +6029,49 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat "created_at": "2021-04-26 09:54", "time_ago": "1分钟前" } +

    退出项目

    +

    供项目成员(开发者、报告者)退出项目用

    + +
    +

    示例:

    +
    +
    curl -X POST http://localhost:3000/api/ceshi1/ceshi_repo1/quit.json
    +
    await octokit.request('POST /api/:owner/:repo/quit.json')
    +

    HTTP 请求

    +

    POST /api/:owner/:repo/quit.json

    +

    请求参数

    + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "status": 0,
    +    "message": "success"
    +}
     

    Repositories

    仓库详情

    仓库详情

    From a6e50d2a250168a0cb981d403a6a4ec65a37ea5b Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 27 May 2022 10:48:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20devops=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=BF=80=E6=B4=BB=E9=A1=B9=E7=9B=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/projects_controller.rb | 2 +- .../concerns/ci/cloud_account_manageable.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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