Skip to content

Commit 4aa8d8b

Browse files
committed
Merge branch 'redmine-6' of https://github.com/noshutdown-ru/vault into redmine-6
# Conflicts: # app/controllers/keys_controller.rb # app/controllers/tags_controller.rb
2 parents 094acd3 + 3198d21 commit 4aa8d8b

File tree

7 files changed

+11
-12
lines changed

7 files changed

+11
-12
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ group :test, :development do
88
gem 'byebug'
99
gem 'capybara-screenshot'
1010
end
11-

app/controllers/keys_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class KeysController < ApplicationController
1010
helper ContextMenusHelper
1111

1212
def index
13-
1413
unless Setting.plugin_vault['use_redmine_encryption'] ||
1514
Setting.plugin_vault['use_null_encryption']
1615
if not Setting.plugin_vault['encryption_key'] or Setting.plugin_vault['encryption_key'].empty?
@@ -129,10 +128,10 @@ def copy
129128

130129
def create
131130
save_file if key_params[:file]
132-
@key = Vault::Key.new(key_params)
133-
131+
@key = Vault::Key.new
132+
@key.safe_attributes = key_params.except(:tags)
134133
@key.project = @project
135-
134+
136135
self.update_wishlist
137136

138137
respond_to do |format|
@@ -148,6 +147,7 @@ def update
148147
save_file if key_params[:file]
149148
respond_to do |format|
150149
self.update_wishlist
150+
@key.safe_attributes = key_params.except(:tags)
151151

152152
if @key.update(key_params)
153153
@key.tags = key_params[:tags]

app/controllers/tags_controller.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def create
1818
end
1919

2020
def update
21-
if @tag.update(tag_params)
21+
@tag.safe_attributes = tag_params
22+
if @tag.save
2223
redirect_to project_key_tags_path(@project, @key), notice: 'Tag was successfully updated.'
2324
else
2425
render :index
@@ -47,4 +48,4 @@ def find_tag
4748
def tag_params
4849
params.require(:tag).permit(:name, :color)
4950
end
50-
end
51+
end

app/models/vault/key.rb

-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def self.import(file)
4646
whitelist: rhash['comment']
4747
).update_column(:id, rhash['id'])
4848
rescue
49-
5049
end
5150
else
5251
begin
@@ -85,5 +84,4 @@ def whitelisted?(user, project)
8584

8685
class Vault::KeysVaultTags < ActiveRecord::Base
8786
end
88-
8987
end

app/models/vault/key_file.rb

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Vault
22
class KeyFile < Key
33
before_update :update_file, if: :file_changed?
44
before_destroy :delete_file
5-
65
private
76

87
def update_file

app/models/vault/tag.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ class Tag < ActiveRecord::Base
33
include Redmine::SafeAttributes
44

55
self.table_name = 'vault_tags'
6-
has_and_belongs_to_many :keys, join_table: 'keys_vault_tags'
6+
has_and_belongs_to_many :keys
7+
8+
safe_attributes 'name', 'color'
79

810
safe_attributes 'name', 'color'
911

assets/javascripts/vault.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ $(function () {
3030
hiddenLabel.toggle();
3131
hiddenLabel.prev().toggle();
3232
}
33-
});
33+
});

0 commit comments

Comments
 (0)