Beispiel #1
0
 /**
  * register hooks for the cache
  */
 public static function registerCacheHooks()
 {
     //don't try to do this before we are properly setup
     if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
         // NOTE: This will be replaced to use OCP
         $userSession = self::$server->getUserSession();
         $userSession->listen('\\OC\\User', 'postLogin', function () {
             try {
                 $cache = new \OC\Cache\File();
                 $cache->gc();
             } catch (\Exception $e) {
                 // a GC exception should not prevent users from using OC,
                 // so log the exception
                 \OC::$server->getLogger()->warning('Exception when running cache gc: ' . $e->getMessage(), array('app' => 'core'));
             }
         });
     }
 }
Beispiel #2
0
 /**
  * Check login: apache auth, auth token, basic auth
  *
  * @param OCP\IRequest $request
  * @return boolean
  */
 private static function handleLogin(OCP\IRequest $request)
 {
     $userSession = self::$server->getUserSession();
     if (OC_User::handleApacheAuth()) {
         return true;
     }
     if ($userSession->tryTokenLogin($request)) {
         return true;
     }
     if ($userSession->tryBasicAuthLogin($request)) {
         return true;
     }
     return false;
 }
Beispiel #3
0
 /**
  * register hooks for the cache
  */
 public static function registerCacheHooks()
 {
     //don't try to do this before we are properly setup
     if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
         // NOTE: This will be replaced to use OCP
         $userSession = self::$server->getUserSession();
         $userSession->listen('\\OC\\User', 'postLogin', function () {
             $cache = new \OC\Cache\File();
             $cache->gc();
         });
     }
 }
Beispiel #4
0
 protected static function handleLogin()
 {
     OC_App::loadApps(array('prelogin'));
     $error = array();
     $messages = [];
     try {
         // auth possible via apache module?
         if (OC::tryApacheAuth()) {
             $error[] = 'apacheauthfailed';
         } elseif (OC::tryRememberLogin()) {
             $error[] = 'invalidcookie';
         } elseif (OC::tryFormLogin()) {
             $error[] = 'invalidpassword';
         }
     } catch (\OC\User\LoginException $e) {
         $messages[] = $e->getMessage();
     } catch (\Exception $ex) {
         \OCP\Util::logException('handleLogin', $ex);
         // do not disclose information. show generic error
         $error[] = 'internalexception';
     }
     if (!\OC::$server->getUserSession()->isLoggedIn()) {
         $loginMessages = array(array_unique($error), $messages);
         \OC::$server->getSession()->set('loginMessages', $loginMessages);
         // Read current user and append if possible
         $args = [];
         if (isset($_POST['user'])) {
             $args['user'] = $_POST['user'];
         }
         $redirectionTarget = \OC::$server->getURLGenerator()->linkToRoute('core.login.showLoginForm', $args);
         header('Location: ' . $redirectionTarget);
     }
 }
Beispiel #5
0
 private static function registerEncryptionHooks()
 {
     $enabled = self::$server->getEncryptionManager()->isEnabled();
     if ($enabled) {
         $user = \OC::$server->getUserSession()->getUser();
         $uid = '';
         if ($user) {
             $uid = $user->getUID();
         }
         $updater = new \OC\Encryption\Update(new \OC\Files\View(), new \OC\Encryption\Util(new \OC\Files\View(), \OC::$server->getUserManager(), \OC::$server->getConfig()), \OC\Files\Filesystem::getMountManager(), \OC::$server->getEncryptionManager(), \OC::$server->getEncryptionFilesHelper(), $uid);
         \OCP\Util::connectHook('OCP\\Share', 'post_shared', $updater, 'postShared');
         \OCP\Util::connectHook('OCP\\Share', 'post_unshare', $updater, 'postUnshared');
     }
 }