From b40520850487de59994fc3a22c6c5519d1b6b9fc Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Thu, 13 Oct 2022 14:54:06 +0200 Subject: [PATCH] Add Safeties before using Settings (#430) --- app/helpers/application_helper.rb | 2 +- app/models/feedback.rb | 2 +- .../devise/mailer/email_changed.html.erb | 2 +- .../devise/mailer/password_change.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/layouts/bare.html.erb | 2 +- app/views/layouts/login.html.erb | 2 +- app/views/layouts/naked.html.erb | 2 +- app/views/passwords/audit.html.erb | 12 ++- app/views/passwords/preview.html.erb | 11 ++- app/views/shared/_email_footer.html.erb | 2 +- app/views/shared/_footer.html.erb | 4 +- app/views/shared/_header.html.erb | 12 +-- app/views/shared/_layout_icons.html.erb | 2 +- config/environments/development.rb | 42 +++++------ config/environments/private.rb | 72 +++++++++--------- config/environments/production.rb | 74 ++++++++++--------- config/initializers/devise.rb | 2 +- config/initializers/translation.rb | 2 +- 19 files changed, 133 insertions(+), 118 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2b48e21e193..a84e3872996 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ module ApplicationHelper # Set the HTML title for the page with a trailing site identifier. def title(content) - if Settings.brand.title + if Settings.brand && Settings.brand.title return content_for(:html_title) { "#{content} | #{Settings.brand.title}" } else return content_for(:html_title) { "#{content} | #{_('Password Pusher')}" } diff --git a/app/models/feedback.rb b/app/models/feedback.rb index 41d53f81516..f74145a3d0f 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -16,7 +16,7 @@ def headers from: Settings.mail.mailer_sender } - if Settings.brand.title + if Settings.brand && Settings.brand.title headers[:subject] = Settings.brand.title + ' Feedback' else headers[:subject] = _('Password Pusher Feedback') diff --git a/app/views/devise/mailer/email_changed.html.erb b/app/views/devise/mailer/email_changed.html.erb index 56df6d8e55b..2e54c8b4b75 100644 --- a/app/views/devise/mailer/email_changed.html.erb +++ b/app/views/devise/mailer/email_changed.html.erb @@ -2,7 +2,7 @@

<%= _('We\'re contacting you to notify you that your email at') %> - <% if Settings.brand.title %> + <% if Settings.brand && Settings.brand.title %> <%= link_to Settings.brand.title, root_url %> <% else %> <%= link_to _('Password Pusher'), root_url %> diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb index eaa67563638..75356cd2174 100644 --- a/app/views/devise/mailer/password_change.html.erb +++ b/app/views/devise/mailer/password_change.html.erb @@ -2,7 +2,7 @@

<%= _('We\'re contacting you to notify you that your password has been changed on') %> - <% if Settings.brand.title %> + <% if Settings.brand && Settings.brand.title %> <%= link_to Settings.brand.title, root_url %>. <% else %> <%= link_to _('Password Pusher'), root_url %>. diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e053a37fd49..72240592046 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,7 @@ -<% if Settings.brand.title %> +<% if Settings.brand && Settings.brand.title %> <%= content_for?(:html_title) ? yield(:html_title) : Settings.brand.title %> <% else %> <%= content_for?(:html_title) ? yield(:html_title) : _('Password Pusher') %> diff --git a/app/views/layouts/bare.html.erb b/app/views/layouts/bare.html.erb index d674fab6ecf..33694f74547 100644 --- a/app/views/layouts/bare.html.erb +++ b/app/views/layouts/bare.html.erb @@ -3,7 +3,7 @@ -<% if Settings.brand.title %> +<% if Settings.brand && Settings.brand.title %> <%= content_for?(:html_title) ? yield(:html_title) : Settings.brand.title %> <% else %> <%= content_for?(:html_title) ? yield(:html_title) : _('Password Pusher') %> diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index d71fe317df7..b7888a28839 100644 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -3,7 +3,7 @@ -<% if Settings.brand.title %> +<% if Settings.brand && Settings.brand.title %> <%= content_for?(:html_title) ? yield(:html_title) : Settings.brand.title %> <% else %> <%= content_for?(:html_title) ? yield(:html_title) : _('Password Pusher') %> diff --git a/app/views/layouts/naked.html.erb b/app/views/layouts/naked.html.erb index 1ef7b7d7154..5cea76e0854 100644 --- a/app/views/layouts/naked.html.erb +++ b/app/views/layouts/naked.html.erb @@ -3,7 +3,7 @@ -<% if Settings.brand.title %> +<% if Settings.brand && Settings.brand.title %> <%= content_for?(:html_title) ? yield(:html_title) : Settings.brand.title %> <% else %> <%= content_for?(:html_title) ? yield(:html_title) : _('Password Pusher') %> diff --git a/app/views/passwords/audit.html.erb b/app/views/passwords/audit.html.erb index 83dc21f0eb6..b83a8b56799 100644 --- a/app/views/passwords/audit.html.erb +++ b/app/views/passwords/audit.html.erb @@ -10,16 +10,20 @@

<%= _('Secret URL for this push') %>:

- + <% if Settings.language_codes %> + + <% end %> + <% if Settings.language_codes %> + + <% end %>