public function testSuccessfulValidateCallsRedirectToNormalPageWhenNoRequestedPage() { $userSession = new UserSession(1); $userSession->HomepageId = 2; $this->fakeServer->UserSession = $userSession; $this->auth->_ValidateResult = true; $this->presenter->Login(); $this->assertEquals(Pages::UrlFromId(2), $this->page->_LastRedirect); }
public function testRedirectsToHomepageIfUserIsActive() { $this->user->SetStatus(AccountStatus::ACTIVE); $this->user->ChangeDefaultHomePage(2); $this->postRegistration->HandleSelfRegistration($this->user, $this->page, $this->context); $this->assertTrue($this->fakeAuth->_LoginCalled); $this->assertEquals($this->user->EmailAddress(), $this->fakeAuth->_LastLogin); $this->assertFalse($this->fakeAuth->_LastLoginContext->GetData()->Persist); $this->assertEquals(Pages::UrlFromId(2), $this->page->_RedirectDestination); }
public function HandleSelfRegistration(User $user, IRegistrationPage $page, ILoginContext $loginContext) { if ($user->StatusId() == AccountStatus::ACTIVE) { Log::Debug('PostRegistration - Handling activate user %s', $user->EmailAddress()); $this->authentication->Login($user->EmailAddress(), $loginContext); $page->Redirect(Pages::UrlFromId($user->Homepage())); } else { Log::Debug('PostRegistration - Handling pending user %s', $user->EmailAddress()); $this->activation->Notify($user); $page->Redirect(Pages::ACTIVATION); } }
public function testActivatesAccount() { $user = new FakeUser(12); $activationSuccess = new ActivationResult(true, $user); $this->accountActivation->_ActivationResult = $activationSuccess; $activationCode = uniqid(); $this->page->expects($this->once())->method('GetActivationCode')->will($this->returnValue($activationCode)); $this->page->expects($this->once())->method('Redirect')->with($this->equalTo(Pages::UrlFromId($user->Homepage()))); $this->presenter->PageLoad(); $this->assertEquals($activationCode, $this->accountActivation->_LastActivationCode); $this->assertTrue($this->auth->_LoginCalled); $this->assertEquals($user->EmailAddress(), $this->auth->_LastLogin); $this->assertEquals(new WebLoginContext(new LoginData(false, $user->Language())), $this->auth->_LastLoginContext); }
public function PageLoad() { $activationCode = $this->page->GetActivationCode(); if (empty($activationCode)) { $this->page->ShowSent(); } else { $activationResult = $this->accountActivation->Activate($activationCode); if ($activationResult->Activated()) { $user = $activationResult->User(); $this->authentication->Login($user->EmailAddress(), new WebLoginContext(new LoginData(false, $user->Language()))); $this->page->Redirect(Pages::UrlFromId($user->Homepage())); } else { $this->page->ShowError(); } } }
private function _Redirect() { $redirect = $this->_page->GetResumeUrl(); if (!empty($redirect)) { $this->_page->Redirect(html_entity_decode($redirect)); } else { $defaultId = ServiceLocator::GetServer()->GetUserSession()->HomepageId; $url = Pages::UrlFromId($defaultId); $this->_page->Redirect(empty($url) ? Pages::UrlFromId(Pages::DEFAULT_HOMEPAGE_ID) : $url); } }
protected function __construct($titleKey = '', $pageDepth = 0) { $this->SetSecurityHeaders(); $this->path = str_repeat('../', $pageDepth); $this->server = ServiceLocator::GetServer(); $resources = Resources::GetInstance(); ExceptionHandler::SetExceptionHandler(new WebExceptionHandler(array($this, 'RedirectToError'))); $this->smarty = new SmartyPage($resources, $this->path); $userSession = ServiceLocator::GetServer()->GetUserSession(); $this->smarty->assign('Charset', $resources->Charset); $this->smarty->assign('CurrentLanguage', $resources->CurrentLanguage); $this->smarty->assign('HtmlLang', $resources->HtmlLang); $this->smarty->assign('HtmlTextDirection', $resources->TextDirection); $this->smarty->assign('Title', 'Booked - ' . $resources->GetString($titleKey)); $this->smarty->assign('CalendarJSFile', $resources->CalendarLanguageFile); $this->smarty->assign('LoggedIn', $userSession->IsLoggedIn()); $this->smarty->assign('Version', Configuration::VERSION); $this->smarty->assign('Path', $this->path); $this->smarty->assign('ScriptUrl', Configuration::Instance()->GetScriptUrl()); $this->smarty->assign('UserName', !is_null($userSession) ? $userSession->FirstName : ''); $this->smarty->assign('DisplayWelcome', $this->DisplayWelcome()); $this->smarty->assign('UserId', $userSession->UserId); $this->smarty->assign('CanViewAdmin', $userSession->IsAdmin); $this->smarty->assign('CanViewGroupAdmin', $userSession->IsGroupAdmin); $this->smarty->assign('CanViewResourceAdmin', $userSession->IsResourceAdmin); $this->smarty->assign('CanViewScheduleAdmin', $userSession->IsScheduleAdmin); $this->smarty->assign('CanViewResponsibilities', !$userSession->IsAdmin && ($userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin)); $allowAllUsersToReports = Configuration::Instance()->GetSectionKey(ConfigSection::REPORTS, ConfigKeys::REPORTS_ALLOW_ALL, new BooleanConverter()); $this->smarty->assign('CanViewReports', $allowAllUsersToReports || $userSession->IsAdmin || $userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin); $timeout = Configuration::Instance()->GetKey(ConfigKeys::INACTIVITY_TIMEOUT); if (!empty($timeout)) { $this->smarty->assign('SessionTimeoutSeconds', max($timeout, 1) * 60); } $this->smarty->assign('ShouldLogout', $this->GetShouldAutoLogout()); $this->smarty->assign('CssExtensionFile', Configuration::Instance()->GetKey(ConfigKeys::CSS_EXTENSION_FILE)); $this->smarty->assign('UseLocalJquery', Configuration::Instance()->GetKey(ConfigKeys::USE_LOCAL_JQUERY, new BooleanConverter())); $this->smarty->assign('EnableConfigurationPage', Configuration::Instance()->GetSectionKey(ConfigSection::PAGES, ConfigKeys::PAGES_ENABLE_CONFIGURATION, new BooleanConverter())); $this->smarty->assign('ShowParticipation', !Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_PREVENT_PARTICIPATION, new BooleanConverter())); $this->smarty->assign('LogoUrl', 'booked.png'); if (file_exists($this->path . 'img/custom-logo.png')) { $this->smarty->assign('LogoUrl', 'custom-logo.png'); } if (file_exists($this->path . 'img/custom-logo.gif')) { $this->smarty->assign('LogoUrl', 'custom-logo.gif'); } if (file_exists($this->path . 'img/custom-logo.jpg')) { $this->smarty->assign('LogoUrl', 'custom-logo.jpg'); } $this->smarty->assign('CssUrl', 'null-style.css'); if (file_exists($this->path . 'css/custom-style.css')) { $this->smarty->assign('CssUrl', 'custom-style.css'); } $logoUrl = Configuration::Instance()->GetKey(ConfigKeys::HOME_URL); if (empty($logoUrl)) { $logoUrl = $this->path . Pages::UrlFromId($userSession->HomepageId); } $this->smarty->assign('HomeUrl', $logoUrl); }