From a0078b7920104047811fcd9f428096e8cffff377 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Mon, 23 Dec 2019 16:57:37 +0100
Subject: [PATCH] FEAT #12735 TIME 0:20 admin email server with enabled from
 field

---
 .../configuration/controllers/ConfigurationController.php   | 4 +++-
 .../sendmail/sendmail-administration.component.html         | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/app/configuration/controllers/ConfigurationController.php b/src/app/configuration/controllers/ConfigurationController.php
index f45ecadb966..7f241cb4778 100755
--- a/src/app/configuration/controllers/ConfigurationController.php
+++ b/src/app/configuration/controllers/ConfigurationController.php
@@ -82,6 +82,9 @@ class ConfigurationController
         if (!Validator::stringType()->notEmpty()->validate($aArgs['type'])) {
             return ['errors' => 'Configuration type is missing', 'code' => 400];
         }
+        if (!Validator::stringType()->notEmpty()->validate($aArgs['from'])) {
+            return ['errors' => 'Configuration from is missing or not well formatted', 'code' => 400];
+        }
         
         if (in_array($aArgs['type'], ['smtp', 'mail'])) {
             $check = Validator::stringType()->notEmpty()->validate($aArgs['host']);
@@ -92,7 +95,6 @@ class ConfigurationController
                 $check = $check && Validator::stringType()->notEmpty()->validate($aArgs['password']);
             }
             $check = $check && Validator::stringType()->validate($aArgs['secure']);
-            $check = $check && Validator::stringType()->validate($aArgs['from']);
             if (!$check) {
                 return ['errors' => "Configuration data is missing or not well formatted", 'code' => 400];
             }
diff --git a/src/frontend/app/administration/sendmail/sendmail-administration.component.html b/src/frontend/app/administration/sendmail/sendmail-administration.component.html
index 6b503170afe..c78d5729297 100644
--- a/src/frontend/app/administration/sendmail/sendmail-administration.component.html
+++ b/src/frontend/app/administration/sendmail/sendmail-administration.component.html
@@ -80,10 +80,10 @@
                                     </mat-form-field>
                                 </div>
                             </div>
-                            <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'">
+                            <div class="form-group">
                                 <div class="col-md-12">
                                     <mat-form-field>
-                                        <input name="mailFrom" [(ngModel)]="sendmail.from" [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1"
+                                        <input name="mailFrom" [(ngModel)]="sendmail.from" required
                                             matInput placeholder="{{lang.mailFrom}}" pattern="(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)">
                                     </mat-form-field>
                                 </div>
@@ -125,4 +125,4 @@
             </div>
         </mat-sidenav>
     </mat-sidenav-container>
-</div>
\ No newline at end of file
+</div>
-- 
GitLab