예제 #1
0
 public function test_addUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("asdfafasfasdf");
     $User->commit();
     return $User;
 }
예제 #2
0
 public function test_createUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("letmein1234");
     $User->commit();
     return $User;
 }
예제 #3
0
 public function test_newUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("BanControl");
     $User->commit();
     return $User;
 }
예제 #4
0
 public function test_addUser()
 {
     $User = new User();
     $User->username = "******";
     $User->setPassword('asfdasdf');
     $User->contact_email = "*****@*****.**";
     $User->commit();
     return $User;
 }
예제 #5
0
 public function test_createUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("asdfadfa1111zz");
     $User->commit();
     $User->setUserAccountStatus(User::STATUS_ACTIVE);
     return $User;
 }
예제 #6
0
 public function testAddUser()
 {
     $User = new User();
     $User->username = self::AUTHOR;
     $User->setPassword('zasdfasdfadfag');
     $User->contact_email = "*****@*****.**";
     $User->commit();
     $this->assertFalse(!filter_var($User->id, FILTER_VALIDATE_INT));
     return $User;
 }
예제 #7
0
 /**
  * Create a demo user
  */
 public function testCreateDemoUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->provider = "railpage";
     $User->setPassword("thisisnotmypassword");
     $User->commit();
     return $User;
 }
예제 #8
0
 public function test_createUser($username = "******", $email = "*****@*****.**")
 {
     $User = new User();
     $User->username = $username;
     $User->contact_email = $email;
     $User->setPassword(md5(time()));
     $User->commit();
     $User->setUserAccountStatus(User::STATUS_ACTIVE);
     return $User;
 }
예제 #9
0
 public function testAddUser()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("letmein1234");
     $User->commit();
     $this->assertFalse(!filter_var($User->id, FILTER_VALIDATE_INT));
     return $User->id;
 }
예제 #10
0
 /**
  * Commit changes to this warning
  *
  * @since Version 3.8.7
  * @return void
  */
 public function commit()
 {
     $this->validate();
     $data = array("new_warning_level" => trim($this->level), "old_warning_level" => $this->level - trim($this->adjustment), "warn_reason" => trim($this->reason), "actiontaken" => trim($this->action), "mod_comments" => trim($this->comments), "user_id" => $this->Recipient->id, "warned_by" => $this->Issuer->id, "warn_date" => $this->Date->getTimestamp());
     $this->db->insert("phpbb_warnings", $data);
     $this->id = $this->db->lastInsertId();
     $this->Recipient->warning_level = $this->level;
     $this->Recipient->commit();
     $Message = new Message();
     $Message->setRecipient($this->Recipient);
     $Message->setAuthor($this->Issuer);
     $Message->subject = "You have received an official warning from Railpage";
     $Message->body = sprintf("%s,\n\nYou have been issued a warning for breaching our Terms of Use or Rules for Posting.\n\n[b]Reason[/b]\n%s\n\n[b]Action taken[/b]\n%s\n\nRegards,\n%s\n\nRailpage Moderator Team.", $this->Recipient->username, $this->reason, $this->action, $this->Issuer->username);
     $Message->send();
 }
예제 #11
0
 /**
  * @depends testAddItem
  */
 public function test_logContributor($Item)
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword('sadfasdfaf');
     $User->commit();
     $Event = new SiteEvent();
     $Event->user_id = $User->id;
     $Event->module_name = "help";
     $Event->title = "Help item created";
     $Event->args = array();
     $Event->key = "help_id";
     $Event->value = $Item->id;
     $Event->commit();
     $contributors = $Item->getContributors();
     $this->assertTrue(count($contributors) > 0);
 }
예제 #12
0
 public function test_addEvent()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword('sadfasdfaf');
     $User->commit();
     $Event = new SiteEvent();
     $Event->user_id = $User->id;
     $Event->module_name = "help";
     $Event->title = "Help item created";
     $Event->args = array();
     $Event->key = "help_id";
     $Event->value = 1;
     $Event->commit();
     $Event = new SiteEvent($Event->id);
     $Event->title = "sdfasdfadf";
     $Event->commit();
 }
예제 #13
0
 public function test_isEmailAvailable()
 {
     $User = new User();
     $User->username = "******";
     $User->contact_email = "*****@*****.**";
     $User->setPassword("letmein1234");
     $this->assertTrue($User->isEmailAvailable("*****@*****.**"));
     $User->commit();
     $this->assertFalse($User->isEmailAvailable("*****@*****.**"));
     $this->assertFalse($User->isEmailAvailable());
     $Base = new Base();
     $this->assertFalse($Base->email_available("*****@*****.**"));
     $this->assertTrue($Base->email_available("*****@*****.**"));
     $this->assertfalse($Base->email_available());
     $Admin = new Admin();
     $this->assertFalse($Admin->email_available("*****@*****.**"));
     $User = new User();
     $this->setExpectedException("Exception", "Cannot check if email address is available because no email address was provided");
     $this->assertFalse($User->isEmailAvailable());
 }
예제 #14
0
 public function testCreateUser()
 {
     $User = new User();
     $User->username = __FUNCTION__;
     $User->contact_email = sprintf("*****@*****.**", $User->username);
     $User->setPassword("sdfadfa7986asfsdf");
     $User->commit();
     return $User;
 }
예제 #15
0
 /**
  * Validate a password for this account
  *
  * Updated to use PHP 5.5's password_hash(), password_verify() and password_needs_rehash() functions
  * @since Version 3.8.7
  *
  * @param string $password
  *
  * @return boolean
  */
 public function validatePassword($password = false, $username = false)
 {
     Utility\PasswordUtility::validateParameters($password, $username, $this);
     /**
      * Create a temporary instance of the requested user for logging purposes
      */
     try {
         $TmpUser = Factory::CreateUserFromUsername($username);
     } catch (Exception $e) {
         if ($e->getMessage() == "Could not find user ID from given username") {
             $TmpUser = new User($this->id);
         }
     }
     /**
      * Get the stored password for this username
      */
     if ($username && !empty($username) && empty($this->username)) {
         $query = "SELECT user_id, user_password, user_password_bcrypt FROM nuke_users WHERE username = ?";
         $row = $this->db->fetchRow($query, $username);
         $stored_user_id = $row['user_id'];
         $stored_pass = $row['user_password'];
         $stored_pass_bcrypt = $row['user_password_bcrypt'];
     } elseif (!empty($this->password)) {
         $stored_user_id = $this->id;
         $stored_pass = $this->password;
         $stored_pass_bcrypt = $this->password_bcrypt;
     }
     /**
      * Check if the invalid auth timeout is in effect
      */
     if (isset($TmpUser->meta['InvalidAuthTimeout'])) {
         if ($TmpUser->meta['InvalidAuthTimeout'] <= time()) {
             unset($TmpUser->meta['InvalidAuthTimeout']);
             unset($TmpUser->meta['InvalidAuthCounter']);
             $TmpUser->commit();
             $this->refresh();
         } else {
             $TmpUser->addNote("Login attempt while InvalidAuthTimeout is in effect");
             throw new Exception("You've attempted to log in with the wrong password too many times. We've temporarily disabled your account to protect it against hackers. Please try again soon. <a href='/account/resetpassword'>Can't remember your password?</a>");
         }
     }
     /**
      * Verify the password
      */
     if (Utility\PasswordUtility::validatePassword($password, $stored_pass, $stored_pass_bcrypt)) {
         $this->load($stored_user_id);
         /**
          * Check if the password needs rehashing
          */
         if (password_needs_rehash($stored_pass, PASSWORD_DEFAULT) || password_needs_rehash($stored_pass_bcrypt, PASSWORD_DEFAULT)) {
             $this->setPassword($password);
         }
         /**
          * Reset the InvalidAuthCounter
          */
         if (isset($this->meta['InvalidAuthCounter'])) {
             unset($this->meta['InvalidAuthCounter']);
         }
         if (isset($this->meta['InvalidAuthTimeout'])) {
             unset($this->meta['InvalidAuthTimeout']);
         }
         $this->commit();
         return true;
     }
     /**
      * Unsuccessful login attempt - bump up the invalid auth counter
      */
     $TmpUser->meta['InvalidAuthCounter'] = !isset($TmpUser->meta['InvalidAuthCounter']) ? 1 : $TmpUser->meta['InvalidAuthCounter']++;
     $TmpUser->addNote(sprintf("Invalid login attempt %d", $TmpUser->meta['InvalidAuthCounter']));
     $TmpUser->commit();
     $this->refresh();
     if ($TmpUser->meta['InvalidAuthCounter'] === 3) {
         $TmpUser->meta['InvalidAuthTimeout'] = strtotime("+10 minutes");
         $TmpUser->addNote("Too many invalid login attempts - account disabled for ten minutes");
         $TmpUser->commit();
         $this->refresh();
         throw new Exception("You've attempted to log in with the wrong password too many times. As a result, we're disabling this account for the next ten minutes. <a href='/account/resetpassword'>Can't remember your password?</a>");
     }
     $this->reset();
     return false;
 }
예제 #16
0
 /**
  * @depends test_newUser
  */
 public function test_validateEmail_Existing($User)
 {
     $this->setExpectedException("Exception", sprintf("The requested email address %s is already in use by a different user.", $User->contact_email));
     $NewUser = new User();
     $NewUser->username = "******";
     $NewUser->contact_email = $User->contact_email;
     $NewUser->setPassword("letmein1234");
     $NewUser->commit();
     $NewUser->validateEmail($NewUser->contact_email);
 }
예제 #17
0
 /**
  * @depends testAddIdea
  */
 public function testCanVote($idea_id)
 {
     $User = new User($this->author_id);
     $Idea = new Idea($idea_id);
     $this->assertFalse($Idea->canVote($User));
     unset($User);
     $User = new User();
     $User->username = __METHOD__;
     $User->contact_email = "*****@*****.**";
     $User->setPassword("asdfafasfafsdff23434");
     $User->commit();
     $this->assertTrue($Idea->canVote($User));
     $Idea->vote($User);
     $this->assertEquals(1, $Idea->getVotes());
     $this->assertFalse($Idea->canVote($User));
     $this->assertEquals(1, count($Idea->getVoters()));
 }