Skip to content

Commit

Permalink
bugfix #22
Browse files Browse the repository at this point in the history
  • Loading branch information
noshutdown-ru-user committed Feb 2, 2018
1 parent f880d6e commit 7698d28
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 33 deletions.
26 changes: 17 additions & 9 deletions app/controllers/keys_controller.rb
Expand Up @@ -48,7 +48,7 @@ def index
end

@keys = @keys.order(sort_clause) unless @keys.nil?

@keys = @keys.select { |key| key.whitelisted?(User,@project) }
@keys = [] if @keys.nil? #hack for decryption

@limit = per_page_option
Expand All @@ -60,8 +60,6 @@ def index
@keys = @keys.offset(@offset).limit(@limit)
end

@keys = @keys.select { |key| key.whitelisted?(User,@project) }

@keys.map(&:decrypt!)
end

Expand Down Expand Up @@ -118,16 +116,26 @@ def update_wishlist
end

def edit
@key.decrypt!
respond_to do |format|
format.html { render action: 'edit'}
if !@key.whitelisted?(User,@project)
render_error t("error.key.not_whitelisted")
return
else
@key.decrypt!
respond_to do |format|
format.html { render action: 'edit'}
end
end
end

def show
@key.decrypt!
respond_to do |format|
format.html { render action: 'show'}
if !@key.whitelisted?(User,@project)
render_error t("error.key.not_whitelisted")
return
else
@key.decrypt!
respond_to do |format|
format.html { render action: 'show'}
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/vault/key.rb
Expand Up @@ -54,4 +54,4 @@ def whitelisted?(user,project)
class Vault::KeysVaultTags < ActiveRecord::Base
end

end
end
36 changes: 18 additions & 18 deletions app/views/keys/index.html.erb
Expand Up @@ -31,24 +31,24 @@
</h2>

<%= form_tag({}, :data => {:cm_url => project_keys_context_menus_path(@project)}) do %>
<table class='list' id='keys_table'>
<thead><tr>
<th class="checkbox hide-when-print">
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
</th>
<%= sort_header_tag('name', caption: t('key.attr.name')) %>
<th><%= t('key.attr.url') %></th>
<th><%= t('key.attr.login') %></th>
<th><%= t('key.attr.body') %> </th>
<th><%= t('key.btn.actions') %></th>
</tr></thead>
<tbody>
<% @keys.each do |key| %>
<%= render partial: key, locals: {parity: cycle('odd', 'even')} %>
<% end %>
</tbody>
</table>
<table class='list' id='keys_table'>
<thead><tr>
<th class="checkbox hide-when-print">
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
</th>
<%= sort_header_tag('name', caption: t('key.attr.name')) %>
<th><%= t('key.attr.url') %></th>
<th><%= t('key.attr.login') %></th>
<th><%= t('key.attr.body') %> </th>
<th><%= t('key.btn.actions') %></th>
</tr></thead>
<tbody>
<% @keys.each do |key| %>
<%= render partial: key, locals: {parity: cycle('odd', 'even')} %>
<% end %>
</tbody>
</table>
<% end %>
<% if Redmine::VERSION.to_s.start_with?('3.3') %>
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Expand Up @@ -88,4 +88,5 @@ en:

error:
key:
not_set: "The encryption key is not set in the settings"
not_set: "The encryption key is not set in the settings"
not_whitelisted: "Key not allowed for you"
3 changes: 2 additions & 1 deletion config/locales/it.yml
Expand Up @@ -88,4 +88,5 @@ it:

error:
key:
not_set: "La chiave crittografata non è definita nelle impostazioni"
not_set: "La chiave crittografata non è definita nelle impostazioni"
not_whitelisted: "Chiave non consentita per te"
3 changes: 2 additions & 1 deletion config/locales/nl.yml
Expand Up @@ -88,4 +88,5 @@ nl:

error:
key:
not_set: "De encryptie sleutel is niet gezet in de instellingen"
not_set: "De encryptie sleutel is niet gezet in de instellingen"
not_whitelisted: "Sleutel niet toegestaan voor jou"
3 changes: 2 additions & 1 deletion config/locales/ru.yml
Expand Up @@ -88,4 +88,5 @@ ru:

error:
key:
not_set: "Ключ шифрования не установлен в настройках"
not_set: "Ключ шифрования не установлен в настройках"
not_whitelisted: "Ключ вам не доступен"
1 change: 1 addition & 0 deletions config/locales/zh.yml
Expand Up @@ -89,3 +89,4 @@ zh:
error:
key:
not_set: "选项钥设置加密方法及密钥"
not_whitelisted: "关键不允许你"
2 changes: 1 addition & 1 deletion init.rb
Expand Up @@ -7,7 +7,7 @@
name 'Vault plugin'
author 'noshutdown.ru'
description 'Plugin for keep keys and passwords'
version '0.3.4'
version '0.3.5'
url 'https://noshutdown.ru/redmine-plugins-vault/'
author_url 'https://noshutdown.ru/'

Expand Down

0 comments on commit 7698d28

Please sign in to comment.