]> git.openstreetmap.org Git - rails.git/commitdiff
Reconfigure the suspended flash message to avoid html_safe
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 17 Nov 2022 12:01:45 +0000 (12:01 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 17 Nov 2022 12:04:28 +0000 (12:04 +0000)
This also avoids having raw html in the translation strings

app/controllers/sessions_controller.rb
app/controllers/users_controller.rb
app/views/sessions/_suspended_flash.html.erb [new file with mode: 0644]
config/locales/en.yml

index 9489553a81d438abfcc4620d8e8452cebfaa6d76..2e223393993b1c5fc648ea9f1e0da95afe1b2fb7 100644 (file)
@@ -52,7 +52,7 @@ class SessionsController < ApplicationController
     elsif (user = User.authenticate(:username => username, :password => password, :pending => true))
       unconfirmed_login(user)
     elsif User.authenticate(:username => username, :password => password, :suspended => true)
-      failed_login t("sessions.new.account is suspended", :webmaster => "mailto:#{Settings.support_email}").html_safe, username
+      failed_login({ :partial => "sessions/suspended_flash" }, username)
     else
       failed_login t("sessions.new.auth failure"), username
     end
index 603feb4dbe9e7c0cddaad1193dc16331af2659fe..1e927aa01d71b2d80c0ff94ce2d9832d2d3239eb 100644 (file)
@@ -290,7 +290,7 @@ class UsersController < ApplicationController
         when "active", "confirmed"
           successful_login(user, request.env["omniauth.params"]["referer"])
         when "suspended"
-          failed_login t("sessions.new.account is suspended", :webmaster => "mailto:#{Settings.support_email}").html_safe
+          failed_login({ :partial => "sessions/suspended_flash" })
         else
           failed_login t("sessions.new.auth failure")
         end
diff --git a/app/views/sessions/_suspended_flash.html.erb b/app/views/sessions/_suspended_flash.html.erb
new file mode 100644 (file)
index 0000000..b8ca550
--- /dev/null
@@ -0,0 +1,2 @@
+<p><%= t ".suspended" %></p>
+<p><%= t ".contact_support_html", :support_link => mail_to(Settings.support_email, t(".support")) %></p>
index c560ded1c258b3a8d86210dabda76b7ed3cc151e..6b072bd1eff160b0351d2a5276253b8fa7e1efcd 100644 (file)
@@ -1782,7 +1782,6 @@ en:
       create account minute: Create an account. It only takes a minute.
       no account: Don't have an account?
       account not active: "Sorry, your account is not active yet.<br />Please use the link in the account confirmation email to activate your account, or <a href=\"%{reconfirm}\">request a new confirmation email</a>."
-      account is suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact <a href="%{webmaster}">support</a> if you wish to discuss this.
       auth failure: "Sorry, could not log in with those details."
       openid_logo_alt: "Log in with an OpenID"
       auth_providers:
@@ -1814,6 +1813,10 @@ en:
       title: "Logout"
       heading: "Logout from OpenStreetMap"
       logout_button: "Logout"
+    suspended_flash:
+      suspended: Sorry, your account has been suspended due to suspicious activity.
+      contact_support_html: Please contact %{support_link} if you wish to discuss this.
+      support: support
   shared:
     markdown_help:
       title_html: Parsed with <a href="https://kramdown.gettalong.org/quickref.html">kramdown</a>