summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-11-27 14:10:11 -0800
committerMorris Jobke <morris.jobke@gmail.com>2013-11-27 14:10:11 -0800
commit54b24ca88d34bfdafaeecb12c9c8ba85e21de8f7 (patch)
treeab7a5d00e1e593522abc186cb029fef560aec703
parent5295993144bf7a67fdcd48c9f8e99e336fd1293e (diff)
parent55d7cf8ffd1170f2397fecefaeef5749bb182f32 (diff)
downloadnextcloud-server-54b24ca88d34bfdafaeecb12c9c8ba85e21de8f7.tar.gz
nextcloud-server-54b24ca88d34bfdafaeecb12c9c8ba85e21de8f7.zip
Merge pull request #6048 from owncloud/encryption_initial_enc_indicator
show a message at the log-in screen if inital encryption take place
-rw-r--r--apps/files_encryption/ajax/getMigrationStatus.php27
-rw-r--r--apps/files_encryption/appinfo/app.php3
-rw-r--r--apps/files_encryption/js/detect-migration.js29
-rw-r--r--apps/files_encryption/lib/util.php32
-rw-r--r--core/css/styles.css9
-rw-r--r--core/templates/login.php6
6 files changed, 89 insertions, 17 deletions
diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php
new file mode 100644
index 00000000000..4da035a97d4
--- /dev/null
+++ b/apps/files_encryption/ajax/getMigrationStatus.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Copyright (c) 2013, Bjoern Schiessle <schiessle@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ *
+ * @brief check migration status
+ */
+use OCA\Encryption\Util;
+
+\OCP\JSON::checkAppEnabled('files_encryption');
+
+$user = isset($_POST['user']) ? $_POST['user'] : '';
+$password = isset($_POST['password']) ? $_POST['password'] : '';
+
+$migrationCompleted = true;
+
+if ($user !== '' && $password !== '') {
+ if (\OCP\User::checkPassword($user, $password)) {
+ $util = new Util(new \OC_FilesystemView('/'), $user);
+ if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
+ $migrationCompleted = false;
+ }
+ }
+}
+
+\OCP\JSON::success(array('data' => array('migrationCompleted' => $migrationCompleted)));
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index c930ac9eca8..fd9aa429b01 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -10,6 +10,8 @@ OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php';
OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php';
OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php';
+\OCP\Util::addscript('files_encryption', 'detect-migration');
+
if (!OC_Config::getValue('maintenance', false)) {
OC_FileProxy::register(new OCA\Encryption\Proxy());
@@ -52,4 +54,3 @@ if (!OC_Config::getValue('maintenance', false)) {
// Register settings scripts
OCP\App::registerAdmin('files_encryption', 'settings-admin');
OCP\App::registerPersonal('files_encryption', 'settings-personal');
-
diff --git a/apps/files_encryption/js/detect-migration.js b/apps/files_encryption/js/detect-migration.js
new file mode 100644
index 00000000000..301e77f24f7
--- /dev/null
+++ b/apps/files_encryption/js/detect-migration.js
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2013
+ * Bjoern Schiessle <schiessle@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ */
+
+
+$(document).ready(function(){
+ $('form[name="login"]').on('submit', function() {
+ var user = $('#user').val();
+ var password = $('#password').val();
+ $.ajax({
+ type: 'POST',
+ url: OC.linkTo('files_encryption', 'ajax/getMigrationStatus.php'),
+ dataType: 'json',
+ data: {user: user, password: password},
+ async: false,
+ success: function(response) {
+ if (response.data.migrationCompleted === false) {
+ var message = t('files_encryption', 'Initial encryption started... This can take some time. Please wait.');
+ $('#messageText').text(message);
+ $('#message').removeClass('hidden').addClass('update');
+ }
+ }
+ });
+ });
+
+});
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 33ab3f56965..434ed225644 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1245,7 +1245,6 @@ class Util {
$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?';
$args = array($this->userId);
-
$query = \OCP\DB::prepare($sql);
$result = $query->execute($args);
@@ -1266,20 +1265,23 @@ class Util {
// If no record is found
if (empty($migrationStatus)) {
\OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR);
- // insert missing entry in DB with status open
- $sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
- $args = array(
- $this->userId,
- 'server-side',
- 0,
- self::MIGRATION_OPEN
- );
- $query = \OCP\DB::prepare($sql);
- $query->execute($args);
-
- return self::MIGRATION_OPEN;
- // If a record is found
- } else {
+ // insert missing entry in DB with status open if the user exists
+ if (\OCP\User::userExists($this->userId)) {
+ $sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
+ $args = array(
+ $this->userId,
+ 'server-side',
+ 0,
+ self::MIGRATION_OPEN
+ );
+ $query = \OCP\DB::prepare($sql);
+ $query->execute($args);
+
+ return self::MIGRATION_OPEN;
+ } else {
+ return false;
+ }
+ } else { // If a record is found
return (int)$migrationStatus[0];
}
diff --git a/core/css/styles.css b/core/css/styles.css
index 5c0aa1fedc2..859f11ff0a8 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -283,6 +283,11 @@ input[type="submit"].enabled {
opacity: .6;
}
+#body-login p#message img {
+ vertical-align: middle;
+ padding: 5px;
+}
+
#body-login div.buttons { text-align:center; }
#body-login p.info {
width: 22em;
@@ -481,6 +486,10 @@ label.infield { cursor:text !important; top:1.05em; left:.85em; }
color: #ccc;
}
+#body-login .update img.float-spinner {
+ float: left;
+}
+
#body-user .warning, #body-settings .warning {
margin-top: 8px;
padding: 5px;
diff --git a/core/templates/login.php b/core/templates/login.php
index aca42c84387..b81128a3269 100644
--- a/core/templates/login.php
+++ b/core/templates/login.php
@@ -1,5 +1,5 @@
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]-->
-<form method="post">
+<form method="post" name="login">
<fieldset>
<?php if (!empty($_['redirect_url'])) {
print_unescaped('<input type="hidden" name="redirect_url" value="' . OC_Util::sanitizeHTML($_['redirect_url']) . '" />');
@@ -18,6 +18,10 @@
<small><?php p($l->t('Please contact your administrator.')); ?></small>
</div>
<?php endif; ?>
+ <p id="message" class="hidden">
+ <img class="float-spinner" src="<?php p(\OCP\Util::imagePath('core', 'loading-dark.gif'));?>"/>
+ <span id="messageText"></span>
+ </p>
<p class="infield grouptop">
<input type="text" name="user" id="user" placeholder=""
value="<?php p($_['username']); ?>"<?php p($_['user_autofocus'] ? ' autofocus' : ''); ?>