Example #1
0
 /**
  * Extra test: load by email when there are multiple users matching.
  * @depends testSetAttributes
  * @depends testLoadByEmailFindUser
  * @depends testLoadByEmailNotFindPreviousEmail
  */
 public function testLoadByEmailWithMultipleMatches()
 {
     global $testUserId1;
     $this->createEmailUsers();
     $object = new User($testUserId1);
     $object->loadByEmail("*****@*****.**");
     $this->assertEquals("Test User 4", $object->getName());
 }
Example #2
0
    $body .= '<p>Note: If you did not request this password change, please contact the ' . PIPELINE_NAME . ' staff.</p>';
    $newEmail = array('to' => $user->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Password changed for ' . $user->getUsername(), 'message' => $body);
    Email::send($newEmail);
    // redirect
    Session::setMessage('Your password was reset. Please check your email for the new password.');
    $json = array('success' => '1', 'successUrl' => Url::logIn());
    exit(json_encode($json));
} elseif ($action == 'login') {
    // assign POST vars to local vars after escaping and removing unwanted spacing.
    if (!empty($_POST['username']) && !empty($_POST['password'])) {
        $username = Filter::text($_POST['username']);
        $password = sha1(Filter::text($_POST['password']));
        $referer = Filter::text($_POST['referer']);
        // figure out if user provided username or email address
        if (Filter::email($username)) {
            $user = User::loadByEmail($username);
        } else {
            $user = User::loadByUsername($username);
        }
        if ($user != null) {
            if ($password == $user->getPassword()) {
                // remember user?
                $remember = Filter::text($_POST['remember']);
                $remember = $remember == 'remember' ? true : false;
                // sign in
                Session::signIn($user->getID(), $remember);
                // send us onward
                if (!empty($referer) && $referer != Url::forgotPassword()) {
                    $json = array('success' => '1', 'successUrl' => $referer);
                } else {
                    $json = array('success' => 1);
Example #3
0
 $trusted = Filter::numeric($_POST['trusted']);
 $invitees = explode(',', $invitees);
 // these arrays will hold valid users and emails to invite
 $users = array();
 $emails = array();
 // first, make sure everyone in the list is valid
 if (!empty($invitees)) {
     foreach ($invitees as $i) {
         $i = trim($i);
         if ($i == '') {
             continue;
         }
         // skip blank
         if (filter_var($i, FILTER_VALIDATE_EMAIL)) {
             // it's an email address
             $user = User::loadByEmail($i);
             if ($user !== null) {
                 // user already registered with this email
                 if ($project->isCreator($user->getID())) {
                     $json = array('error' => $user->getUsername() . ' (' . $i . ') is the creator of this project.');
                     exit(json_encode($json));
                 } elseif ($project->isTrusted($user->getID())) {
                     $json = array('error' => $user->getUsername() . ' (' . $i . ') is already a trusted member of this project.');
                     exit(json_encode($json));
                 } elseif ($project->isMember($user->getID())) {
                     $json = array('error' => $user->getUsername() . ' (' . $i . ') is already a member of this project.');
                     exit(json_encode($json));
                 } else {
                     // add user to array
                     $users[] = $user;
                 }
 public function isDataValid()
 {
     var_dump($this->data);
     if (!filter_var($this->data['email'], FILTER_VALIDATE_EMAIL) || strlen($this->data['email']) < 8 || strlen($this->data['email']) > 50) {
         $this->message = "Geen geldig emailadres";
         return false;
     }
     $user = new User();
     if (!$user->loadByEmail($this->data['email'])) {
         $this->message = "Emailadres is niet bij ons geregistreerd";
         return false;
     } else {
         $this->guid = $user->guid;
         $this->username = $user->username;
     }
     return true;
 }
Example #5
0
 }
 if ($pw != $pw2) {
     $json = array('error' => 'Sorry, your passwords do not match.');
     exit(json_encode($json));
 }
 // validate email address
 if ($email == "") {
     $json = array('error' => 'You must provide a valid email address to register.');
     exit(json_encode($json));
 }
 if (!Filter::email($email)) {
     $json = array('error' => 'You must provide a valid email address to register.');
     exit(json_encode($json));
 }
 // must be unique email
 $ue = User::loadByEmail($email);
 if (!empty($ue)) {
     $json = array('error' => 'That email address is already in use.');
     exit(json_encode($json));
 }
 // must provide birthdate
 if ($month == "0" || $year == "0") {
     $json = array('error' => 'You must select a valid birth month and year to register.');
     exit(json_encode($json));
 }
 // convert birthdate to MySQL format
 $dob = $year . "-" . $month . "-01";
 // convert password to MD5 hash
 $pw = sha1($pw);
 // instantiate a User with this data
 $user = new User();