/** * Start a session if required username/password exist in the system * * @param Context $Context * @param Authenticator $Authenticator * @param int $UserID */ function Start(&$Context, $Authenticator, $UserID = '0') { $this->StartSession($Context); // If the UserID is not explicitly defined (ie. by some vanilla-based login module), // retrieve the authenticated UserID from the Authenticator module. $this->UserID = ForceInt($UserID, 0); if ($this->UserID == 0) { $this->UserID = $Authenticator->GetIdentity(); } // Now retrieve user information if ($this->UserID > 0) { $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager'); $this->User = $UserManager->GetSessionDataById($this->UserID); // If the session data retrieval failed for some reason, dump the user if (!$this->User) { $this->User = $Context->ObjectFactory->NewContextObject($Context, 'User'); $this->User->Clear(); $this->UserID = 0; } } else { $this->User = $Context->ObjectFactory->NewContextObject($Context, 'User'); $this->User->Clear(); } }