/** Reads the submitted data from the password assistance form.
  * 
  * The following form fields are read as HTTP POST parameters:
  * username
  * email
  *
  * If the submitted username and email address matches an entry in the user data 
  * table, then ILIAS creates a password assistance session for the user, and
  * sends a password assistance mail to the email address.
  * For details about the creation of the session and the e-mail see function
  * sendPasswordAssistanceMail().
  */
 function submitUsernameAssistanceForm()
 {
     global $tpl, $ilias, $lng, $rbacadmin, $rbacreview;
     require_once './Services/User/classes/class.ilObjUser.php';
     require_once "./Services/Utilities/classes/class.ilUtil.php";
     // Retrieve form data
     $email = ilUtil::stripSlashes($_POST["email"]);
     // Retrieve a user object with matching user name and email address.
     $logins = ilObjUser::_getUserIdsByEmail($email);
     // No matching user object found?
     // Show the password assistance form again, and display an error message.
     if (count($logins) < 1) {
         $this->showUsernameAssistanceForm($lng->txt("pwassist_invalid_email"), "", $email);
     } elseif (!strlen($email)) {
         $this->showUsernameAssistanceForm($lng->txt("pwassist_invalid_email"), "", $email);
     } else {
         $this->sendUsernameAssistanceMail($email, $logins);
         $this->showMessageForm(null, sprintf($lng->txt("pwassist_mail_sent"), $email));
     }
 }
Esempio n. 2
0
 /**
  * Auth and email related methods
  * @group IL_Init
  */
 public function testAuthAndEmailMethods()
 {
     include_once "./Services/User/classes/class.ilObjUser.php";
     $value = "";
     // creation
     $user = new ilObjUser();
     $d = array("login" => "aatestuser2", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "f", "firstname" => "Heidi", "lastname" => "Kabel", "email" => "*****@*****.**", "ext_account" => "ext_");
     $user->assignData($d);
     $user->setActive(true);
     $user->create();
     $user->saveAsNew();
     $user->setLanguage("de");
     $user->writePrefs();
     $id = $user->getId();
     ilObjUser::_writeExternalAccount($id, "ext_kabel");
     ilObjUser::_writeAuthMode($id, "cas");
     $ids = ilObjUser::_getUserIdsByEmail("*****@*****.**");
     //var_dump($ids);
     if (is_array($ids) && count($ids) == 1 && $ids[0] == "aatestuser2") {
         $value .= "email1-";
     }
     $uid = ilObjUser::getUserIdByEmail("*****@*****.**");
     if ($uid == $id) {
         $value .= "email2-";
     }
     $acc = ilObjUser::_getExternalAccountsByAuthMode("cas");
     foreach ($acc as $k => $v) {
         if ($k == $id && $v == "ext_kabel") {
             $value .= "auth1-";
         }
     }
     if (ilObjUser::_lookupAuthMode($id) == "cas") {
         $value .= "auth2-";
     }
     if (ilObjUser::_checkExternalAuthAccount("cas", "ext_kabel") == "aatestuser2") {
         $value .= "auth3-";
     }
     if (ilObjUser::_externalAccountExists("ext_kabel", "cas")) {
         $value .= "auth4-";
     }
     ilObjUser::_getNumberOfUsersPerAuthMode();
     $la = ilObjUser::_getLocalAccountsForEmail("*****@*****.**");
     ilObjUser::_incrementLoginAttempts($id);
     ilObjUser::_getLoginAttempts($id);
     ilObjUser::_resetLoginAttempts($id);
     ilObjUser::_setUserInactive($id);
     // deletion
     $user->delete();
     $this->assertEquals("email1-email2-auth1-auth2-auth3-auth4-", $value);
 }
 /**
  * Reads the submitted data from the password assistance form.
  * The following form fields are read as HTTP POST parameters:
  * username
  * email
  * If the submitted username and email address matches an entry in the user data
  * table, then ILIAS creates a password assistance session for the user, and
  * sends a password assistance mail to the email address.
  * For details about the creation of the session and the e-mail see function
  * sendPasswordAssistanceMail().
  */
 public function submitUsernameAssistanceForm()
 {
     require_once 'Services/User/classes/class.ilObjUser.php';
     require_once 'Services/Utilities/classes/class.ilUtil.php';
     $form = $this->getUsernameAssistanceForm();
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         $this->showUsernameAssistanceForm($form);
         return;
     }
     // Retrieve form data
     $email = $form->getInput('email');
     // Retrieve a user object with matching user name and email address.
     $logins = ilObjUser::_getUserIdsByEmail($email);
     // No matching user object found?
     // Show the password assistance form again, and display an error message.
     if (!is_array($logins) || count($logins) < 1) {
         ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_invalid_email')));
         $form->setValuesByPost();
         $this->showUsernameAssistanceForm($form);
     } else {
         $this->sendUsernameAssistanceMail($email, $logins);
         $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
     }
 }