--- /dev/null
+<?php
+if (!isset($_)) { //also provide standalone error page
+ require_once '../../../lib/base.php';
+
+ $l = OC_L10N::get('files_encryption');
+
+ // check if ajax request
+ if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Your private key is not valid! Maybe the your password was changed from outside.'))));
+ } else {
+ header('HTTP/1.0 404 ' . $l->t('Your private key is not valid! Maybe the your password was changed from outside.'));
+ $tmpl = new OC_Template('files_encryption', 'invalid_private_key', 'guest');
+ $tmpl->printPage();
+ }
+
+ exit;
+}
+?>
return $relPath;
}
+
+ /**
+ * @brief redirect to a error page
+ */
+ public static function redirectToErrorPage() {
+ $location = \OC_Helper::linkToAbsolute('apps/files_encryption/files', 'error.php');
+ header('Location: ' . $location);
+ exit();
+ }
}
\ No newline at end of file
} else {
+ if($this->privateKey === false) {
+ // if private key is not valid redirect user to a error page
+ \OCA\Encryption\Helper::redirectToErrorPage();
+ }
+
$this->size = $this->rootView->filesize($this->rawPath, $mode);
}
// if there is no valid private key return false
if ($this->privateKey === false) {
- if (\OC_Util::isCallRegistered()) {
- $l = \OC_L10N::get('core');
- \OCP\JSON::error(array('data' => array('message' => $l->t('Private key is not valid! Maybe the user password was changed from outside if so please change it back to gain access'))));
- throw new \Exception('Private key for user "' . $this->userId
- . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access');
- }
+ // if private key is not valid redirect user to a error page
+ \OCA\Encryption\Helper::redirectToErrorPage();
return false;
}
// if there is no valid private key return false
if ($this->privateKey === false) {
- if (\OC_Util::isCallRegistered()) {
- $l = \OC_L10N::get('core');
- \OCP\JSON::error(array('data' => array('message' => $l->t('Private key is not valid! Maybe the user password was changed from outside if so please change it back to gain access'))));
-
// cleanup
if ($this->meta['mode'] !== 'r' && $this->meta['mode'] !== 'rb') {
\OC_FileProxy::$enabled = $proxyStatus;
}
- throw new \Exception('Private key for user "' . $this->userId
- . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access');
- }
-
-
- return false;
+ // if private key is not valid redirect user to a error page
+ \OCA\Encryption\Helper::redirectToErrorPage();
}
if (