コード例 #1
0
ファイル: BeeHub_Sponsor.php プロジェクト: niekbosch/BeeHub
 public function is_requested($user = null)
 {
     $this->init_props();
     if (is_null($user)) {
         $user = BeeHub::getAuth()->current_user();
     } elseif (!$user instanceof BeeHub_User) {
         $user = BeeHub::user($user);
     }
     return ($tmp = @$this->users[$user->path]) && !$tmp['is_accepted'];
 }
コード例 #2
0
ファイル: BeeHub_Auth.php プロジェクト: niekbosch/BeeHub
 /**
  * Sets the current user
  *
  * @param   string  $user_name  The user name, or null to indicate no user is logged in
  * @return  void
  */
 private function set_user($user_name)
 {
     if (is_null($user_name)) {
         $this->currentUserPrincipal = null;
     } else {
         $this->currentUserPrincipal = BeeHub::user($user_name);
     }
 }
コード例 #3
0
ファイル: beehubTest.php プロジェクト: niekbosch/BeeHub
 public function testUser()
 {
     $user = $this->getMock('BeeHub_User', array('init_props'), array('/system/users/test_user'));
     $user->expects($this->any())->method('init_props');
     $registryMock = $this->getMock('BeeHub_Registry', array('resource'));
     $registryMock->expects($this->once())->method('resource')->will($this->returnValue($user));
     \DAV::$REGISTRY = $registryMock;
     $this->assertSame($user, \BeeHub::user('/system/users/test_user'), 'BeeHub::user() should return a user if the path is correct');
     $registryMockNull = $this->getMock('BeeHub_Registry', array('resource'));
     $registryMockNull->expects($this->once())->method('resource')->will($this->returnValue(null));
     \DAV::$REGISTRY = $registryMockNull;
     $this->setExpectedException('DAV_Status');
     \BeeHub::group('/system/users/test_user', null, \DAV::HTTP_FORBIDDEN);
 }
コード例 #4
0
ファイル: password_reset.php プロジェクト: niekbosch/BeeHub
 // POST requests will either send you a reset code or, if a code is given, it will reset your password
 //First try to get the username
 $username = null;
 if (isset($_POST['username']) && !empty($_POST['username'])) {
     $username = $_POST['username'];
 } elseif (isset($_POST['email']) && !empty($_POST['email'])) {
     $collection = BeeHub::getNoSQL()->users;
     $result = $collection->findOne(array('email' => $_POST['email']), array('name' => true));
     if (!is_null($result)) {
         $username = $result['name'];
     }
 }
 // Then find the actual user
 $user = null;
 try {
     $user = BeeHub::user($username);
 } catch (DAV_Status $exception) {
     // We don't care yet whether we found a valid user, because that will be checked depending on what the user is actually trying to do.
 }
 // Check whether we need to send a reset code or need to check it
 if (isset($_POST['reset_code']) && !empty($_POST['reset_code'])) {
     if (!is_null($user) && (isset($_POST['new_password']) && !empty($_POST['new_password'])) && (isset($_POST['new_password2']) && $_POST['new_password'] === $_POST['new_password2']) && $user->check_password_reset_code($_POST['reset_code'])) {
         $user->set_password($_POST['new_password']);
         require 'views/password_reset_done.php';
     } else {
         BeeHub::htmlError('<p>The form was not correctly filled out.</p>', DAV::HTTP_BAD_REQUEST);
     }
 } else {
     // Send a new reset code
     if (!is_null($user)) {
         $reset_code = $user->create_password_reset_code();