public function __construct()
 {
     $this->request = \OC::$server->getRequest();
     $this->config = \OC::$server->getSystemConfig();
     $this->redirectUrl = $this->request->getRequestUri();
     $this->defaultPageUrl = \OC_Util::getDefaultPageUrl();
     $this->visitPort = (int) $_SERVER["SERVER_PORT"];
     if ($this->config->getValue("sso_multiple_region")) {
         array_push(self::$requiredKeys, "sso_owncloud_url");
         array_push(self::$requiredKeys, "sso_regions");
     }
     foreach ($this->necessaryImplementationClass as $class) {
         if (!class_exists($class)) {
             throw new Exception("The class " . $class . " did't exist.");
         }
     }
     self::checkKeyExist(self::$requiredKeys);
     RequestManager::init($this->config->getValue("sso_portal_url"), $this->config->getValue("sso_requests"));
 }
Esempio n. 2
0
 /**
  * Test default apps
  *
  * @dataProvider defaultAppsProvider
  */
 function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps)
 {
     $oldDefaultApps = \OCP\Config::getSystemValue('core', 'defaultapp', '');
     // CLI is doing messy stuff with the webroot, so need to work it around
     $oldWebRoot = \OC::$WEBROOT;
     \OC::$WEBROOT = '';
     Dummy_OC_App::setEnabledApps($enabledApps);
     \OCP\Config::setSystemValue('defaultapp', $defaultAppConfig);
     $this->assertEquals('http://localhost/' . $expectedPath, \OC_Util::getDefaultPageUrl());
     // restore old state
     \OC::$WEBROOT = $oldWebRoot;
     Dummy_OC_App::restore();
     \OCP\Config::setSystemValue('defaultapp', $oldDefaultApps);
 }
 public function testShowLoginFormForLoggedInUsers()
 {
     $this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $expectedResponse = new RedirectResponse(\OC_Util::getDefaultPageUrl());
     $this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
 }
Esempio n. 4
0
 /**
  * @PublicPage
  * @NoCSRFRequired
  * @UseSession
  *
  * @param string $user
  * @param string $redirect_url
  * @param string $remember_login
  *
  * @return TemplateResponse
  */
 public function showLoginForm($user, $redirect_url, $remember_login)
 {
     if ($this->userSession->isLoggedIn()) {
         return new RedirectResponse(\OC_Util::getDefaultPageUrl());
     }
     $parameters = array();
     $loginMessages = $this->session->get('loginMessages');
     $errors = [];
     $messages = [];
     if (is_array($loginMessages)) {
         list($errors, $messages) = $loginMessages;
     }
     $this->session->remove('loginMessages');
     foreach ($errors as $value) {
         $parameters[$value] = true;
     }
     $parameters['messages'] = $messages;
     if (!is_null($user) && $user !== '') {
         $parameters['loginName'] = $user;
         $parameters['user_autofocus'] = false;
     } else {
         $parameters['loginName'] = '';
         $parameters['user_autofocus'] = true;
     }
     if (!empty($redirect_url)) {
         $parameters['redirect_url'] = $redirect_url;
     }
     $parameters['canResetPassword'] = true;
     if (!$this->config->getSystemValue('lost_password_link')) {
         if (!is_null($user) && $user !== '') {
             $userObj = $this->userManager->get($user);
             if ($userObj instanceof IUser) {
                 $parameters['canResetPassword'] = $userObj->canChangePassword();
             }
         }
     }
     $parameters['alt_login'] = \OC_App::getAlternativeLogIns();
     $parameters['rememberLoginAllowed'] = \OC_Util::rememberLoginAllowed();
     $parameters['rememberLoginState'] = !empty($remember_login) ? $remember_login : 0;
     if (!is_null($user) && $user !== '') {
         $parameters['loginName'] = $user;
         $parameters['user_autofocus'] = false;
     } else {
         $parameters['loginName'] = '';
         $parameters['user_autofocus'] = true;
     }
     return new TemplateResponse($this->appName, 'login', $parameters, 'guest');
 }
Esempio n. 5
0
 public function testGetDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontController()
 {
     putenv('front_controller_active=true');
     $_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
     $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', OC_Util::getDefaultPageUrl());
 }