Ejemplo n.º 1
0
 /**
  * Load the user object into the user property
  *
  * @return \thebuggenie\core\entities\User
  */
 public static function loadUser($user = null)
 {
     try {
         self::$_user = $user === null ? User::loginCheck(self::getRequest(), self::getCurrentAction()) : $user;
         if (self::$_user->isAuthenticated()) {
             if (self::$_user->isOffline() || self::$_user->isAway()) {
                 self::$_user->setOnline();
             }
             if (!self::getRequest()->hasCookie('tbg3_original_username')) {
                 self::$_user->updateLastSeen();
             }
             if (!self::getScope()->isDefault() && !self::getRequest()->isAjaxCall() && !in_array(self::getRouting()->getCurrentRouteName(), array('add_scope', 'debugger', 'logout')) && !self::$_user->isGuest() && !self::$_user->isConfirmedMemberOfScope(self::getScope())) {
                 self::getResponse()->headerRedirect(self::getRouting()->generate('add_scope'));
             }
             self::$_user->save();
             if (!self::$_user->getGroup() instanceof \thebuggenie\core\entities\Group) {
                 throw new \Exception('This user account belongs to a group that does not exist anymore. <br>Please contact the system administrator.');
             }
         }
     } catch (exceptions\ElevatedLoginException $e) {
         throw $e;
     } catch (\Exception $e) {
         self::$_user = new User();
         throw $e;
     }
     return self::$_user;
 }