Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add validation for mail_from

Oliver Güntherfc59f2b24542
diff --git a/app/controllers/admin/settings/mail_notifications_settings_controller.rb b/app/controllers/admin/settings/mail_notifications_settings_controller.rb
index f2e70374837..56b5d3e876c 100644
--- a/app/controllers/admin/settings/mail_notifications_settings_controller.rb
+++ b/app/controllers/admin/settings/mail_notifications_settings_controller.rb
@@ -32,10 +32,21 @@ module Admin::Settings
:mail_notifications
end
+ before_action :validate_mail_from, only: :update # rubocop:disable Rails/LexicallyScopedActionFilter
+
def show
@deliveries = ActionMailer::Base.perform_deliveries
respond_to :html
end
+
+ private
+
+ def validate_mail_from
+ return if EmailValidator.valid?(settings_params[:mail_from])
+
+ flash[:error] = "#{I18n.t(:setting_mail_from)} #{I18n.t('activerecord.errors.messages.email')}"
+ redirect_to action: :show
+ end
end
end