Blame view
sources/settings/ajax/decryptall.php
1.1 KB
|
31b7f2792
|
1 2 3 4 5 6 7 8 9 10 11 |
<?php
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
//encryption app needs to be loaded
OC_App::loadApp('files_encryption');
// init encryption app
$params = array('uid' => \OCP\User::getUser(),
'password' => $_POST['password']);
|
|
6d9380f96
|
12 |
$view = new OC\Files\View('/');
|
|
31b7f2792
|
13 |
$util = new \OCA\Encryption\Util($view, \OCP\User::getUser()); |
|
6d9380f96
|
14 |
$l = \OC_L10N::get('settings');
|
|
31b7f2792
|
15 16 17 18 |
$result = $util->initEncryption($params);
if ($result !== false) {
|
|
a293d369c
|
19 20 21 22 23 24 25 26 27 |
try {
$successful = $util->decryptAll();
} catch (\Exception $ex) {
\OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR);
$successful = false;
}
$util->closeEncryptionSession();
|
|
31b7f2792
|
28 |
if ($successful === true) {
|
|
6d9380f96
|
29 |
\OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully'))));
|
|
31b7f2792
|
30 |
} else {
|
|
6d9380f96
|
31 |
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator'))));
|
|
31b7f2792
|
32 33 |
}
} else {
|
|
6d9380f96
|
34 |
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again'))));
|
|
31b7f2792
|
35 |
} |