function _password_mail_submit() { $this->_import_login(); $controller = new LoginController($this->api); $user = init_user_from_post_data(); // Make sure that the email address is valid. $err = $user->check_mail(); if ($err) { $controller->add_hint(new \hint\Error($err)); return $controller->show_password_forgotten($user); } // Find the user with the given mail address. $userdb = $this->get_userdb(); $user = $userdb->get_user_from_mail($user->get_mail()); if (!$user) { $user = init_user_from_post_data(); $msg = _('The given email address was not found.'); $controller->add_hint(new \hint\Error($msg)); return $controller->show_password_forgotten($user); } // Send the mail. if (!$user->is_confirmed()) { $url = new FreechURL(cfg('site_url')); $url->set_var('action', 'account_reconfirm'); $url->set_var('username', $user->get_name()); $this->_refer_to($url->get_string()); } elseif ($user->is_active()) { $this->_send_password_reset_mail($user); } elseif ($user->is_locked()) { $controller->add_hint(new \hint\Error(_('Your account is locked.'))); return $controller->show_password_forgotten($user); } else { die('Invalid user status'); } // Done. $controller->show_password_mail_sent($user); }