Example #1
0
  */
 if (!isset($selectedNetwork)) {
     throw new Exception(_("Sorry, this network does not exist !"));
 }
 if (!$selectedNetwork->getAuthenticator()->isRegistrationPermitted()) {
     throw new Exception(_("Sorry, this network does not accept new user registration !"));
 }
 // Validate entered values
 validate_username($username);
 validate_email($email);
 validate_passwords($password, $password_again);
 // Check if user exists
 if (User::getUserByUsernameAndOrigin($username, $selectedNetwork)) {
     throw new Exception(_("Sorry, a user account is already associated to this username. Pick another one."));
 }
 if (User::getUserByEmailAndOrigin($email, $selectedNetwork)) {
     throw new Exception(_("Sorry, a user account is already associated to this email address."));
 }
 // Create user and send him the validation email
 $created_user = User::createUser(get_guid(), $username, $selectedNetwork, $email, $password);
 $created_user->sendValidationEmail();
 // Authenticate this new user automatically
 $errmsg = "";
 $authenticated_user = $selectedNetwork->getAuthenticator()->login($username, $password, $errmsg);
 if (empty($authenticated_user)) {
     throw new Exception(_("Unable to authenticate newly created user.  Please report this bug.  Error was: {$errmsg}"));
 }
 // While in validation period, alert user that he should validate his account ASAP
 $validationMsgHtml = "<div id='warning_message_area'>\n";
 $validationMsgHtml .= _("An email with confirmation instructions was sent to your email address.");
 $validationMsgHtml .= sprintf(_("Your account has been granted %s minutes of access to retrieve your email and validate your account."), $selectedNetwork->getValidationGraceTime() / 60);
Example #2
0
 if (!$_REQUEST['username'] && !$_REQUEST['email']) {
     throw new Exception(_("Please specify a username or email address"));
 }
 $username = $db->escapeString($_REQUEST['username']);
 $email = $db->escapeString($_REQUEST['email']);
 /*
  * Get a list of users associated with either a username of an e-mail
  */
 if ($username && $email) {
     throw new Exception(_("Please specify EITHER your username or your email, not both"));
 } else {
     if ($username) {
         $user = User::getUserByUsernameAndOrigin($username, $account_origin);
     } else {
         if ($email) {
             $user = User::getUserByEmailAndOrigin($email, $account_origin);
         } else {
             throw new Exception(_("You need to specify your username or your email"));
         }
     }
 }
 /*
  * In case that both previous function calls failed to return a users
  * list throw an exception
  */
 if ($user != null) {
     $user->sendLostPasswordEmail();
 } else {
     throw new Exception(_("This username or email could not be found in our database"));
 }
 $smarty->assign('message', _('A new password has been emailed to you.'));
Example #3
0
 /*
  * Main content
  */
 // Reset ALL smarty SWITCH values
 $smarty->assign('sectionTOOLCONTENT', false);
 $smarty->assign('sectionMAINCONTENT', false);
 // Set section of Smarty template
 $smarty->assign('sectionMAINCONTENT', true);
 if (empty($account_origin)) {
     throw new Exception(_("Sorry, this network does not exist !"));
 }
 if (!$_REQUEST["email"]) {
     throw new Exception(_("Please specify an email address"));
 }
 // Get a list of User objects and send mail messages to them
 $user = User::getUserByEmailAndOrigin($_REQUEST['email'], $account_origin);
 if ($user == null) {
     throw new Exception(_("This email could not be found in our database"));
 }
 $user->sendLostUsername();
 $smarty->assign("message", _("Your username has been emailed to you."));
 // Compile HTML code
 $html_body = $smarty->fetch("templates/sites/validate.tpl");
 /*
  * Render output
  */
 $ui = MainUI::getObject();
 $ui->addContent('left_area_middle', $html);
 $ui->addContent('main_area_middle', $html_body);
 $ui->display();
 // We're done ...