[FEATURE] Add email address to installation process 89/60889/7
authorBenni Mack <benni@typo3.org>
Thu, 6 Jun 2019 05:42:49 +0000 (07:42 +0200)
committerFrank Nägler <frank.naegler@typo3.org>
Tue, 24 Sep 2019 09:36:02 +0000 (11:36 +0200)
New installations now ask for the email address as well, so
this can be used later on to e.g. notify the admin if somebody
logged-in (Warning email address).

The same feature is available in the maintenance module of
the Install Tool in the "Create Administrative User" card.

Resolves: #89227
Releases: master
Change-Id: Iafca7043543d5e299fb121d96d9b3b9caa375bc9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60889
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Build/Sources/TypeScript/install/Resources/Public/TypeScript/Module/Maintenance/CreateAdmin.ts
typo3/sysext/core/Documentation/Changelog/master/Feature-89227-AskForEmailAddressWhileInstallingTYPO3.rst [new file with mode: 0644]
typo3/sysext/install/Classes/Controller/InstallerController.php
typo3/sysext/install/Classes/Controller/MaintenanceController.php
typo3/sysext/install/Resources/Private/Templates/Installer/ShowDatabaseData.html
typo3/sysext/install/Resources/Private/Templates/Maintenance/CreateAdmin.html
typo3/sysext/install/Resources/Public/JavaScript/Module/Maintenance/CreateAdmin.js

index 71d4dda..2c1ebc8 100644 (file)
@@ -70,6 +70,7 @@ class CreateAdmin extends AbstractInteractableModule {
           'userName': this.findInModal('.t3js-createAdmin-user').val(),
           'userPassword': this.findInModal('.t3js-createAdmin-password').val(),
           'userPasswordCheck': this.findInModal('.t3js-createAdmin-password-check').val(),
+          'userEmail': this.findInModal('.t3js-createAdmin-email').val(),
           'userSystemMaintainer': (this.findInModal('.t3js-createAdmin-system-maintainer').is(':checked')) ? 1 : 0,
         },
       },
@@ -94,6 +95,7 @@ class CreateAdmin extends AbstractInteractableModule {
     this.findInModal('.t3js-createAdmin-user').val('');
     this.findInModal('.t3js-createAdmin-password').val('');
     this.findInModal('.t3js-createAdmin-password-check').val('');
+    this.findInModal('.t3js-createAdmin-email').val('');
     this.findInModal('.t3js-createAdmin-system-maintainer').prop('checked', false);
   }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-89227-AskForEmailAddressWhileInstallingTYPO3.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-89227-AskForEmailAddressWhileInstallingTYPO3.rst
new file mode 100644 (file)
index 0000000..043dbfd
--- /dev/null
@@ -0,0 +1,20 @@
+.. include:: ../../Includes.txt
+
+==============================================================
+Feature: #89227 - Ask for email address while installing TYPO3
+==============================================================
+
+See :issue:`89227`
+
+Description
+===========
+
+It is now possible to enter an email address for the first admin user while installing TYPO3.
+Within the install process, an admin user will be created by entering a username and password.
+
+For a new installation, the user is asked for the email address as well, so this can be used
+later-on to e.g. notify the admin if somebody logged-in (Warning email address).
+
+This will also work in the install tool Maintenance module "Create Administrative User" card.
+
+.. index:: Backend, ext:install
index 33af40e..6db8f9d 100644 (file)
@@ -635,6 +635,7 @@ class InstallerController
         $username = (string)$postValues['username'] !== '' ? $postValues['username'] : 'admin';
         // Check password and return early if not good enough
         $password = $postValues['password'];
+        $email = $postValues['email'] ?? '';
         if (empty($password) || strlen($password) < 8) {
             $messages[] = new FlashMessage(
                 'You are setting an important password here! It gives an attacker full control over your instance if cracked.'
@@ -674,6 +675,7 @@ class InstallerController
         $adminUserFields = [
             'username' => $username,
             'password' => $this->getHashedPassword($password),
+            'email' => GeneralUtility::validEmail($email) ? $email : '',
             'admin' => 1,
             'tstamp' => $GLOBALS['EXEC_TIME'],
             'crdate' => $GLOBALS['EXEC_TIME']
index 027d56a..2cf509a 100644 (file)
@@ -481,6 +481,7 @@ class MaintenanceController extends AbstractController
         $username = preg_replace('/\\s/i', '', $request->getParsedBody()['install']['userName']);
         $password = $request->getParsedBody()['install']['userPassword'];
         $passwordCheck = $request->getParsedBody()['install']['userPasswordCheck'];
+        $email = $request->getParsedBody()['install']['userEmail'] ?? '';
         $isSystemMaintainer = ((bool)$request->getParsedBody()['install']['userSystemMaintainer'] == '1') ? true : false;
 
         $messages = new FlashMessageQueue('install');
@@ -527,6 +528,9 @@ class MaintenanceController extends AbstractController
                     'tstamp' => $GLOBALS['EXEC_TIME'],
                     'crdate' => $GLOBALS['EXEC_TIME']
                 ];
+                if (GeneralUtility::validEmail($email)) {
+                    $adminUserFields['email'] = $email;
+                }
                 $connectionPool->getConnectionForTable('be_users')->insert('be_users', $adminUserFields);
 
                 if ($isSystemMaintainer) {
index 671dd55..c2265d9 100644 (file)
@@ -15,7 +15,7 @@
         <form method="post" id="stepInstaller-databaseData" class="t3-install-form-label-before form-horizontal">
             <input type="hidden" value="execute" name="install[set]" />
             <div class="form-group">
-                <label for="password" class="control-label col-md-2">Username</label>
+                <label for="username" class="control-label col-md-2">Username</label>
                 <div class="col-md-10">
                     <input
                         class="t3-install-form-input-text form-control"
                     </div>
                 </div>
             </div>
+            <div class="form-group">
+                <label for="email" class="control-label col-md-2">Email address</label>
+                <div class="col-md-10">
+                    <input
+                        type="email"
+                        class="t3-install-form-input-text form-control"
+                        name="install[values][email]"
+                        id="email"
+                    />
+                </div>
+            </div>
             <div class="row">
                 <div class="col-md-2"></div>
                 <div class="col-md-10">
index 682a49f..5a3ed98 100644 (file)
             />
         </div>
         <div class="form-group">
+            <label for="t3-install-admin-email" class="control-label">Email address</label>
+            <input
+                type="email"
+                class="t3-install-form-input-text t3js-createAdmin-email form-control"
+                name="email"
+                id="t3-install-admin-email"
+            />
+        </div>
+        <div class="form-group">
             <div class="checkbox">
-                <label>
+                <label for="typo3-install-admin-add-as-system-maintainer">
                     <input
                         class="t3-install-form-input-checkbox t3js-createAdmin-system-maintainer"
                         type="checkbox"
-                        id="add-as-system-maintainer"
+                        id="typo3-install-admin-add-as-system-maintainer"
                     />
                     Add as system maintainer
                 </label>
index 81de10a..a30a624 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","../AbstractInteractableModule","jquery","../../Router","../PasswordStrength","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Notification"],function(t,e,s,a,r,n,i,o){"use strict";return new class extends s.AbstractInteractableModule{constructor(){super(...arguments),this.selectorAdminCreateButton=".t3js-createAdmin-create"}initialize(t){this.currentModal=t,this.getData(),t.on("click",this.selectorAdminCreateButton,t=>{t.preventDefault(),this.create()}),t.on("click",".t3-install-form-password-strength",t=>{n.initialize(".t3-install-form-password-strength")})}getData(){const t=this.getModalBody();a.ajax({url:r.getUrl("createAdminGetData"),cache:!1,success:e=>{!0===e.success?(t.empty().append(e.html),i.setButtons(e.buttons)):o.error("Something went wrong")},error:e=>{r.handleAjaxError(e,t)}})}create(){const t=this.getModalBody(),e=this.getModuleContent().data("create-admin-token");a.ajax({url:r.getUrl(),method:"POST",data:{install:{action:"createAdmin",token:e,userName:this.findInModal(".t3js-createAdmin-user").val(),userPassword:this.findInModal(".t3js-createAdmin-password").val(),userPasswordCheck:this.findInModal(".t3js-createAdmin-password-check").val(),userSystemMaintainer:this.findInModal(".t3js-createAdmin-system-maintainer").is(":checked")?1:0}},cache:!1,success:t=>{!0===t.success&&Array.isArray(t.status)?t.status.forEach(t=>{2===t.severity?o.error(t.message):o.success(t.title)}):o.error("Something went wrong")},error:e=>{r.handleAjaxError(e,t)}}),this.findInModal(".t3js-createAdmin-user").val(""),this.findInModal(".t3js-createAdmin-password").val(""),this.findInModal(".t3js-createAdmin-password-check").val(""),this.findInModal(".t3js-createAdmin-system-maintainer").prop("checked",!1)}}});
\ No newline at end of file
+define(["require","exports","../AbstractInteractableModule","jquery","../../Router","../PasswordStrength","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Notification"],function(e,t,a,s,r,n,i,d){"use strict";return new class extends a.AbstractInteractableModule{constructor(){super(...arguments),this.selectorAdminCreateButton=".t3js-createAdmin-create"}initialize(e){this.currentModal=e,this.getData(),e.on("click",this.selectorAdminCreateButton,e=>{e.preventDefault(),this.create()}),e.on("click",".t3-install-form-password-strength",e=>{n.initialize(".t3-install-form-password-strength")})}getData(){const e=this.getModalBody();s.ajax({url:r.getUrl("createAdminGetData"),cache:!1,success:t=>{!0===t.success?(e.empty().append(t.html),i.setButtons(t.buttons)):d.error("Something went wrong")},error:t=>{r.handleAjaxError(t,e)}})}create(){const e=this.getModalBody(),t=this.getModuleContent().data("create-admin-token");s.ajax({url:r.getUrl(),method:"POST",data:{install:{action:"createAdmin",token:t,userName:this.findInModal(".t3js-createAdmin-user").val(),userPassword:this.findInModal(".t3js-createAdmin-password").val(),userPasswordCheck:this.findInModal(".t3js-createAdmin-password-check").val(),userEmail:this.findInModal(".t3js-createAdmin-email").val(),userSystemMaintainer:this.findInModal(".t3js-createAdmin-system-maintainer").is(":checked")?1:0}},cache:!1,success:e=>{!0===e.success&&Array.isArray(e.status)?e.status.forEach(e=>{2===e.severity?d.error(e.message):d.success(e.title)}):d.error("Something went wrong")},error:t=>{r.handleAjaxError(t,e)}}),this.findInModal(".t3js-createAdmin-user").val(""),this.findInModal(".t3js-createAdmin-password").val(""),this.findInModal(".t3js-createAdmin-password-check").val(""),this.findInModal(".t3js-createAdmin-email").val(""),this.findInModal(".t3js-createAdmin-system-maintainer").prop("checked",!1)}}});
\ No newline at end of file