auth: create user object regardless of login
[minimedit.git] / widget / contact.php
index b50537517d7b68952f50922a53c244b7763e8e91..b7e073fe40f72890260fcab2f448fd6ca1f3123a 100644 (file)
@@ -2,8 +2,12 @@
 $error = NULL;
 if ($_POST) {
        global $User;
-       if ($User) {
+       if ($User->login) {
                $_REQUEST['login'] = $User->login;
+               $_REQUEST['email'] = $_REQUEST['email'] ?: $User->email;
+       }
+       else {
+               unset($_REQUEST['login']);
        }
        $error = mailform($_REQUEST);
        if (!empty($error)) {
@@ -46,7 +50,7 @@ switch ($source) {
        }
 }
 
-       $reply = preg_match('/\A\w+@\w+\.[a-z]+\z/', @$input['email'])
+       $reply = preg_match('/\A[^\s\'@]{1,64}@[.a-zA-Z0-9-]{4,63}\z/', @$input['email'])
                ? $input['email'] : "noreply@$domain";
        $header = "From: $reply";