예제 #1
0
 protected static function initializeUser()
 {
     TBGLogging::log('Loading user');
     try {
         TBGLogging::log('is this logout?');
         if (self::getRequest()->getParameter('logout')) {
             TBGLogging::log('yes');
             self::logout();
         } else {
             TBGLogging::log('no');
             TBGLogging::log('sets up user object');
             $event = TBGEvent::createNew('core', 'pre_login');
             $event->trigger();
             if ($event->isProcessed()) {
                 self::loadUser($event->getReturnValue());
             } else {
                 self::loadUser();
             }
             TBGEvent::createNew('core', 'post_login', self::getUser())->trigger();
             TBGLogging::log('loaded');
             self::cacheAllPermissions();
         }
     } catch (Exception $e) {
         TBGLogging::log("Something happened while setting up user: " . $e->getMessage(), 'main', TBGLogging::LEVEL_WARNING);
         if (!self::isCLI() && (self::getRouting()->getCurrentRouteModule() != 'main' || self::getRouting()->getCurrentRouteAction() != 'register1' && self::getRouting()->getCurrentRouteAction() != 'register2' && self::getRouting()->getCurrentRouteAction() != 'activate' && self::getRouting()->getCurrentRouteAction() != 'reset_password' && self::getRouting()->getCurrentRouteAction() != 'captcha' && self::getRouting()->getCurrentRouteAction() != 'login' && self::getRouting()->getCurrentRouteAction() != 'getBackdropPartial' && self::getRouting()->getCurrentRouteAction() != 'serve')) {
             self::$_redirect_login = true;
         } else {
             self::$_user = self::factory()->TBGUser(TBGSettings::getDefaultUserID());
         }
     }
     TBGLogging::log('...done');
 }
예제 #2
0
 protected static function initializeUser()
 {
     TBGLogging::log('Loading user');
     try {
         TBGLogging::log('is this logout?');
         if (self::getRequest()->getParameter('logout')) {
             TBGLogging::log('yes');
             self::logout();
         } else {
             TBGLogging::log('no');
             TBGLogging::log('sets up user object');
             $event = TBGEvent::createNew('core', 'pre_login');
             $event->trigger();
             if ($event->isProcessed()) {
                 self::loadUser($event->getReturnValue());
             } elseif (!self::isCLI()) {
                 self::loadUser();
             } else {
                 self::$_user = new TBGUser();
             }
             TBGEvent::createNew('core', 'post_login', self::getUser())->trigger();
             TBGLogging::log('loaded');
             TBGLogging::log('caching permissions');
             self::cacheAllPermissions();
             TBGLogging::log('done (caching permissions)');
         }
     } catch (TBGElevatedLoginException $e) {
         TBGLogging::log("Could not reauthenticate elevated permissions: " . $e->getMessage(), 'main', TBGLogging::LEVEL_INFO);
         TBGContext::setMessage('elevated_login_message_err', $e->getMessage());
         self::$_redirect_login = '******';
     } catch (Exception $e) {
         TBGLogging::log("Something happened while setting up user: " . $e->getMessage(), 'main', TBGLogging::LEVEL_WARNING);
         $allow_anonymous_routes = array('register', 'register_check_username', 'register1', 'register2', 'activate', 'reset_password', 'captcha', 'login', 'login_page', 'getBackdropPartial', 'serve', 'doLogin');
         if (!self::isCLI() && (!in_array(self::getRouting()->getCurrentRouteModule(), array('main', 'remote')) || !in_array(self::getRouting()->getCurrentRouteName(), $allow_anonymous_routes))) {
             TBGContext::setMessage('login_message_err', $e->getMessage());
             self::$_redirect_login = '******';
         } else {
             self::$_user = self::factory()->TBGUser(TBGSettings::getDefaultUserID());
         }
     }
     TBGLogging::log('...done');
 }