示例#1
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     $q = $this->userRepository->createQueryBuilder('u')->select('u, r')->leftJoin('u.role', 'r')->where('u.username = :username OR u.email = :username')->setParameter('username', $username)->getQuery();
     $user = $q->getOneOrNullResult();
     if (empty($user)) {
         $message = sprintf('Unable to find an active admin MauticUserBundle:User object identified by "%s".', $username);
         throw new UsernameNotFoundException($message, 0);
     }
     //load permissions
     if ($user->getId()) {
         $permissions = $this->session->get('mautic.user.permissions', false);
         if ($permissions === false) {
             $permissions = $this->permissionRepository->getPermissionsByRole($user->getRole());
             $this->session->set('mautic.user.permissions', $permissions);
         }
         $user->setActivePermissions($permissions);
     }
     return $user;
 }