Merge branch 'develop' into dev_trustie_server
This commit is contained in:
commit
c6f2021017
|
@ -18,11 +18,11 @@ class PublicKeysController < ApplicationController
|
||||||
if @gitea_response[0] == 201
|
if @gitea_response[0] == 201
|
||||||
@public_key = @gitea_response[2]
|
@public_key = @gitea_response[2]
|
||||||
else
|
else
|
||||||
return render_error("创建ssh key失败") if @gitea_response[2]["message"].nil?
|
return render_error("创建ssh key失败") if @gitea_response[2].blank?
|
||||||
return render_ok({status: 10002, message: "密钥格式不正确"}) if @gitea_response[2]["message"].starts_with?("Invalid key content")
|
return render_ok({status: 10002, message: "密钥格式不正确"}) if @gitea_response[2]["message"].starts_with?("Invalid key content")
|
||||||
exist_public_key = Gitea::PublicKey.find_by(content: public_key_params[:key])
|
exist_public_key = Gitea::PublicKey.find_by(content: public_key_params[:key])
|
||||||
return render_ok({status: 10002, message: "密钥已存在,请勿重复添加"}) if @gitea_response[2]["message"].starts_with?("Key content has been used as non-deploy key") && exist_public_key.owner_id == current_user.gitea_uid
|
return render_ok({status: 10002, message: "密钥已被占用"}) if @gitea_response[2]["message"].starts_with?("Key content has been used as non-deploy key") && exist_public_key.present? && exist_public_key&.owner_id != current_user.gitea_uid
|
||||||
return render_ok({status: 10002, message: "密钥已被占用"}) if @gitea_response[2]["message"].starts_with?("Key content has been used as non-deploy key") && exist_public_key.present?
|
return render_ok({status: 10002, message: "密钥已存在,请勿重复添加"}) if @gitea_response[2]["message"].starts_with?("Key content has been used as non-deploy key")
|
||||||
@public_key = nil
|
@public_key = nil
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -32,7 +32,8 @@ class PublicKeysController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
return render_not_found unless @public_key.present?
|
return render_not_found unless @public_key.present?
|
||||||
if @public_key.destroy
|
result = Gitea::User::Keys::DeleteService.call(current_user.gitea_token, @public_key.id)
|
||||||
|
if result[0] == 204
|
||||||
render_ok
|
render_ok
|
||||||
else
|
else
|
||||||
render_error
|
render_error
|
||||||
|
|
|
@ -81,7 +81,7 @@ module RepositoriesHelper
|
||||||
content = Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content']
|
content = Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content']
|
||||||
readme_render_decode64_content(content, path)
|
readme_render_decode64_content(content, path)
|
||||||
else
|
else
|
||||||
file_type = entry['name'].to_s.split(".").last
|
file_type = File.extname(entry['name'].to_s)[1..-1]
|
||||||
if download_type(file_type)
|
if download_type(file_type)
|
||||||
return entry['content'].nil? ? Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content'] : entry['content']
|
return entry['content'].nil? ? Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content'] : entry['content']
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,8 @@ class Gitea::User::Keys::DeleteService < Gitea::ClientService
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
delete(url, params)
|
response = delete(url, params)
|
||||||
|
render_response(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
json.id @public_key["id"]
|
if @public_key.present?
|
||||||
json.name @public_key["title"]
|
json.status 0
|
||||||
json.content @public_key["key"]
|
json.id @public_key["id"]
|
||||||
json.fingerprint @public_key["fingerprint"]
|
json.name @public_key["title"]
|
||||||
json.created_time @public_key["created_at"].to_time.strftime("%Y/%m/%d %H:%M")
|
json.content @public_key["key"]
|
||||||
|
json.fingerprint @public_key["fingerprint"]
|
||||||
|
json.created_time @public_key["created_at"].to_time.strftime("%Y/%m/%d %H:%M")
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
if @project.forge?
|
if @project.forge?
|
||||||
file_name = entry['name']
|
file_name = entry['name']
|
||||||
file_type = file_name.to_s.split(".").last
|
file_type = File.extname(file_name.to_s)[1..-1]
|
||||||
direct_download = download_type(file_type)
|
direct_download = download_type(file_type)
|
||||||
image_type = image_type?(file_type)
|
image_type = image_type?(file_type)
|
||||||
json.name file_name
|
json.name file_name
|
||||||
|
|
Loading…
Reference in New Issue