Ignore new email in RegisterNewActivationCodeForm if user ignores the 'optional'
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 19 Apr 2015 21:14:41 +0000 (23:14 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 19 Apr 2015 21:14:41 +0000 (23:14 +0200)
wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php

index 0efc11f53bd617448160f97091933b0f389bef9a..813e741f3c0e571c22e650c86a94704b65729238 100644 (file)
@@ -111,13 +111,19 @@ class RegisterNewActivationCodeForm extends AbstractForm {
         */
        public function validateEmail() {
                if (!empty($this->email)) {
-                       if (!UserRegistrationUtil::isValidEmail($this->email)) {
-                               throw new UserInputException('email', 'notValid');
+                       // check whether user entered the same email, instead of leaving the input empty
+                       if (mb_strtolower($this->email) != mb_strtolower($this->user->email)) {
+                               if (!UserRegistrationUtil::isValidEmail($this->email)) {
+                                       throw new UserInputException('email', 'notValid');
+                               }
+                               
+                               // Check if email exists already.
+                               if (!UserUtil::isAvailableEmail($this->email)) {
+                                       throw new UserInputException('email', 'notUnique');
+                               }
                        }
-                       
-                       // Check if email exists already.
-                       if (!UserUtil::isAvailableEmail($this->email)) {
-                               throw new UserInputException('email', 'notUnique');
+                       else {
+                               $this->email = '';
                        }
                }
        }