Example #1
0
 if (empty($account_origin)) {
     throw new Exception(_("Sorry, this network does not exist !"));
 }
 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 {
Example #2
0
 /**
  * Get's the splash-only user.
  *
  * This is the user that people logged-in at a splash-only hotspot will
  * show up as.  This user always has multiple-login capabilities.
  *
  * @param string $username The username of the user
  * @param string $account_origin The account origin
  *
  * @return object A User object
  *
  * @access public
  */
 public function getSplashOnlyUser()
 {
     $username = '******';
     if (!empty($this->splashOnlyUser)) {
         $user = $this->splashOnlyUser;
     } else {
         $user = User::getUserByUsernameAndOrigin($username, $this);
         if (!$user) {
             $user = User::createUser(get_guid(), $username, $this, '', '');
             $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED);
         }
         $this->splashOnlyUser = $user;
     }
     return $user;
 }
 /*
  * 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["username"]) {
     throw new Exception(_("Please specify a username"));
 }
 // Get a list of users with this username
 $user = User::getUserByUsernameAndOrigin($_REQUEST['username'], $account_origin);
 if ($user == null) {
     throw new Exception(_("This username could not be found in our database"));
 }
 $user->sendValidationEmail();
 $smarty->assign('message', _("An email with confirmation instructions was sent to your email address."));
 // 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 ...
Example #4
0
 $htmlToolContent = $smarty->fetch("templates/sites/signup.tpl");
 /*
  * Main content
  */
 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
Example #5
0
 /** Set the user's username
  * @param $value The new value
  * @return true on success, false on failure
  * @throws exception if the user tries to set a duplicate username
  */
 function setUsername($value)
 {
     $retval = true;
     if ($value != $this->getUsername()) {
         $db = AbstractDb::getObject();
         $otherUser = User::getUserByUsernameAndOrigin($value, $this->getNetwork());
         if (!is_null($otherUser)) {
             throw new exception(sprintf(_("Sorry, the username %s is not available"), $value));
         }
         $value = $db->escapeString($value);
         $retval = @$db->execSqlUpdate("UPDATE users SET username = '******' WHERE user_id='{$this->id}'", false);
         $this->refresh();
     }
     return $retval;
 }