From d7d30cf3d71e57d6a5a85501b85babd1f6ad6e76 Mon Sep 17 00:00:00 2001
From: pabois <pierreandre.boissinot@noesya.coop>
Date: Thu, 13 Jul 2023 11:22:34 +0200
Subject: [PATCH] remove autocomplete for access token

---
 app/helpers/application_helper.rb                     | 1 +
 app/views/admin/communication/websites/_form.html.erb | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c234968c2..0acd1311e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -53,6 +53,7 @@ module ApplicationHelper
   def masked_string(string)
     string = string.to_s # in case it was nil
     mask_length = [(string.length - 5), 0].max
+    mask_length = 30 if mask_length > 30
     string.to_s.gsub(/.+(?=.{5})/, '•' * mask_length)
   end
 
diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb
index b74c842aa..ab0b5b565 100644
--- a/app/views/admin/communication/websites/_form.html.erb
+++ b/app/views/admin/communication/websites/_form.html.erb
@@ -25,6 +25,8 @@
               <%= f.input :access_token, 
                           as: :password, 
                           placeholder: masked_string(f.object.access_token), 
+                          autocomplete: 'off',
+                          role: 'presentation',
                           hint: t("simple_form.hints.communication_website.access_token_#{f.object.access_token.blank? ? 'without' : 'with'}_existing").html_safe
                           %>
               <%= f.input :repository %>
-- 
GitLab