Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     $user = new User($username);
     if ($username === $this->session->get('username')) {
         $user->setAuthProvider($this->session->get('owner'));
     }
     return $user;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     $user = new User($username);
     if ($username === $this->session->get('username')) {
         $user->setAuthProvider($this->session->get('owner'));
         $user->setVisibleName($this->session->get('visibleName'));
     }
     $this->adminEnabler->grantRoleAdmin($user);
     return $user;
 }
 /**
  * Test if path for an uploaded contribution file is ok
  */
 public function testGrantRoleAdmin()
 {
     $adminEnabler = new AdminEnabler($this->admins);
     foreach ($this->users as $list) {
         list($authProvider, $username) = $list;
         $user = new User($username);
         $user->setAuthProvider($authProvider);
         $adminEnabler->grantRoleAdmin($user);
         if ($authProvider == 'github' && in_array($username, $this->admins)) {
             $assert = 'assertTrue';
         } else {
             $assert = 'assertFalse';
         }
         $this->{$assert}(in_array('ROLE_ADMIN', $user->getRoles()));
     }
 }
Esempio n. 4
0
 /**
  * Check if user is in the admins list
  *
  * @param User $user
  *
  * @return bool
  */
 public function grantRoleAdmin(User $user)
 {
     if ($user->getAuthProvider() == 'github' && in_array($user->getUsername(), $this->admins)) {
         $user->grantRoleAdmin();
     }
 }