From 752fe9f4053f7f200aa580284842a76919473306 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Sat, 28 Sep 2024 12:14:57 +0200 Subject: [PATCH 1/3] Some controller hooks won't get loaded There are several hooks in lib/redmine_dmsf.rb listed to get loaded but two of them in lib/redmine_dmsf/hooks/controllers are missing: - account_controller_hooks - search_controller_hooks Therefore, webdav digest won't be created and the search feature (not Redmine default) won't be available. --- lib/redmine_dmsf.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/redmine_dmsf.rb b/lib/redmine_dmsf.rb index 417eeaab..33babe90 100644 --- a/lib/redmine_dmsf.rb +++ b/lib/redmine_dmsf.rb @@ -72,7 +72,9 @@ # Hooks def require_hooks + require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/account_controller_hooks" require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/issues_controller_hooks" + require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/controllers/search_controller_hooks" require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/view_projects_form_hook" require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/base_view_hooks" require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/custom_field_view_hooks" From 7a6187236fa9f49eb213a0754f7c5dfd103b5c68 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Sat, 28 Sep 2024 15:25:07 +0200 Subject: [PATCH 2/3] Changes token action name for WebDAV digest The partial views/hooks/redmine_dmsf/_view_my_account.html.erb uses a finder method where the action name still uses kebab case but since migration 20240829093801_rename_dmsf_digest_token.rb it is required to use snake case. That is, dmsf-webdav-digest needs to be renamed to dmsf_webdav_digest to find the token of the current user. --- app/views/hooks/redmine_dmsf/_view_my_account.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/hooks/redmine_dmsf/_view_my_account.html.erb b/app/views/hooks/redmine_dmsf/_view_my_account.html.erb index 642c8e3e..50a44458 100644 --- a/app/views/hooks/redmine_dmsf/_view_my_account.html.erb +++ b/app/views/hooks/redmine_dmsf/_view_my_account.html.erb @@ -31,7 +31,7 @@ <% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>

- <% token = Token.find_by(user_id: @user.id, action: 'dmsf-webdav-digest') %> + <% token = Token.find_by(user_id: @user.id, action: 'dmsf_webdav_digest') %> <% if token %> <%= l(:label_dmsf_webdav_digest_created_on, distance_of_time_in_words(Time.now, token.created_on)) %> <% else %> From 92586c78b13647568423d9e8560aaa3bc638bbd7 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Sat, 28 Sep 2024 20:17:20 +0200 Subject: [PATCH 3/3] Adds further text to reset button of webdav digest When a user has 2FA enabled the WebDAV digest won't be created on sign in. The reason is in RedmineDmsf::Hooks::Controllers:: AccountControllerHooks#controller_account_success_authentication_after where the digest will be created only if the controller parameter ':password' is present. This works for a user authentication with login name and password only. A user with 2fa enabled runs differently through the authentication process and crosses the hook not before the 2fa token was checked. Hence, there won't be a password parameter anymore. Instead of manipulating controller params to provide the password only the button text for reseting the digest will be changed if the user has 2FA but no digest yet. This would make it more explicit that the token is not expected to exist and can be created if missing. --- app/views/hooks/redmine_dmsf/_view_my_account.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/hooks/redmine_dmsf/_view_my_account.html.erb b/app/views/hooks/redmine_dmsf/_view_my_account.html.erb index 642c8e3e..e15939dd 100644 --- a/app/views/hooks/redmine_dmsf/_view_my_account.html.erb +++ b/app/views/hooks/redmine_dmsf/_view_my_account.html.erb @@ -31,12 +31,13 @@ <% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>

- <% token = Token.find_by(user_id: @user.id, action: 'dmsf-webdav-digest') %> + <% token = Token.find_by(user_id: @user.id, action: 'dmsf_webdav_digest') %> <% if token %> <%= l(:label_dmsf_webdav_digest_created_on, distance_of_time_in_words(Time.now, token.created_on)) %> + (<%= link_to l(:button_reset), dmsf_digest_path, remote: true, id: 'webdav_digest_reset' %>) <% else %> <%= l(:label_missing_dmsf_webdav_digest) %> + (<%= link_to l(:button_add), dmsf_digest_path, remote: true, id: 'webdav_digest_reset' %>) <% end %> - (<%= link_to l(:button_reset), dmsf_digest_path, remote: true, id: 'webdav_digest_reset' %>)

<% end %>