From edf62eb41a338319488eb0b71134da2d38d0a7bd Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 8 Jun 2016 10:41:30 +0200 Subject: Add user ID to log entries in admin page --- settings/templates/admin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'settings/templates') diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 0cdefe10083..b5c5b2510b6 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -519,6 +519,7 @@ if ($_['cronErrors']) { p($entry->time); }?> + user) ? p($entry->user) : p('--') ?> -- cgit v1.2.3 From ea25be51dac20ad42a813276794b9df3044b62f5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 15 Jun 2016 15:27:07 +0200 Subject: fix strengthify in personal settings --- settings/css/settings.css | 4 ++-- settings/js/personal.js | 3 ++- settings/templates/personal.php | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'settings/templates') diff --git a/settings/css/settings.css b/settings/css/settings.css index 5fc96343502..0460db929c9 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -529,9 +529,9 @@ span.indeterminate { } /* PASSWORD */ -.strengthify-wrapper { +#passwordform .strengthify-wrapper { position: absolute; - left: 189px; + left: 186px; width: 131px; margin-top: -7px; } diff --git a/settings/js/personal.js b/settings/js/personal.js index aea2400e999..d270a49f3ad 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -343,7 +343,8 @@ $(document).ready(function () { t('core', 'So-so password'), t('core', 'Good password'), t('core', 'Strong password') - ] + ], + drawTitles: true, }); // does the user have a custom avatar? if he does show #removeavatar diff --git a/settings/templates/personal.php b/settings/templates/personal.php index ced76fc3bf6..83a44234b94 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -133,7 +133,6 @@ if($_['passwordChangeSupported']) {
-
Date: Wed, 15 Jun 2016 15:30:23 +0200 Subject: Drop useless IE8 rules --- settings/css/settings.css | 12 ------------ settings/templates/personal.php | 2 -- 2 files changed, 14 deletions(-) (limited to 'settings/templates') diff --git a/settings/css/settings.css b/settings/css/settings.css index 5fc96343502..13b289ea182 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -536,18 +536,6 @@ span.indeterminate { margin-top: -7px; } -.ie8 .strengthify-wrapper { - left: 389px; -} - -.onlyInIE8 { - display: none; -} - -.ie8 .onlyInIE8 { - display: inline; -} - /* OPERA hack for strengthify*/ doesnotexist:-o-prefocus, .strengthify-wrapper { left: 185px; diff --git a/settings/templates/personal.php b/settings/templates/personal.php index ced76fc3bf6..19bba537181 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -121,11 +121,9 @@ if($_['passwordChangeSupported']) {
- - Date: Wed, 15 Jun 2016 23:25:06 +0200 Subject: Re-add labels for password inputs for usability * ref https://github.com/nextcloud/server/pull/112#discussion_r67245286 --- settings/templates/personal.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'settings/templates') diff --git a/settings/templates/personal.php b/settings/templates/personal.php index b4ff5db5c7c..4f3bca63a4e 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -121,9 +121,11 @@ if($_['passwordChangeSupported']) {
+ + Date: Mon, 20 Jun 2016 10:38:37 +0200 Subject: fix more strings --- apps/updatenotification/lib/Notification/Notifier.php | 2 +- apps/updatenotification/templates/admin.php | 2 +- settings/js/apps.js | 2 +- settings/templates/admin.php | 2 +- settings/templates/apps.php | 4 ++-- settings/templates/personal.php | 10 +++++----- settings/templates/settings.development.notice.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'settings/templates') diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php index 50505ef13f6..bd89c11d62d 100644 --- a/apps/updatenotification/lib/Notification/Notifier.php +++ b/apps/updatenotification/lib/Notification/Notifier.php @@ -64,7 +64,7 @@ class Notifier implements INotifier { $l = $this->l10NFactory->get('updatenotification', $languageCode); if ($notification->getObjectType() === 'core') { - $appName = $l->t('ownCloud core'); + $appName = $l->t('Nextcloud core'); $this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions()); } else { diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index 5974b106f72..0be070cac30 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -47,7 +47,7 @@
- t('Only notification for app updates are available, because the selected update channel for ownCloud itself does not allow notifications.')); ?> + t('Only notification for app updates are available, because the selected update channel for the server itself does not allow notifications.')); ?>

diff --git a/settings/js/apps.js b/settings/js/apps.js index 56c9022aa72..525a34d9067 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -121,7 +121,7 @@ OC.Settings.Apps = OC.Settings.Apps || { $('.enable.needs-download').tipsy({fallback: t('settings', 'The app will be downloaded from the app store')}); - $('.app-level .official').tipsy({fallback: t('settings', 'Official apps are developed by and within the Nextcloud community. They offer functionality central to Nextcloud and are ready for production use.')}); + $('.app-level .official').tipsy({fallback: t('settings', 'Official apps are developed by and within the community. They offer central functionality and are ready for production use.')}); $('.app-level .approved').tipsy({fallback: t('settings', 'Approved apps are developed by trusted developers and have passed a cursory security check. They are actively maintained in an open code repository and their maintainers deem them to be stable for casual to normal use.')}); $('.app-level .experimental').tipsy({fallback: t('settings', 'This app is not checked for security issues and is new or known to be unstable. Install at your own risk.')}); }, diff --git a/settings/templates/admin.php b/settings/templates/admin.php index b5c5b2510b6..c0a7424cf67 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -362,7 +362,7 @@ if ($_['cronErrors']) {

t('Please read carefully before activating server-side encryption: ')); ?>

diff --git a/settings/templates/apps.php b/settings/templates/apps.php index d3c14332693..2edbf1530eb 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -117,12 +117,12 @@ script( {{#if missingMinOwnCloudVersion}}
-

t('This app has no minimum ownCloud version assigned. This will be an error in ownCloud 11 and later.')); ?>

+

t('This app has no minimum Nextcloud version assigned. This will be an error in the future.')); ?>

{{else}} {{#if missingMaxOwnCloudVersion}}
-

t('This app has no maximum ownCloud version assigned. This will be an error in ownCloud 11 and later.')); ?>

+

t('This app has no maximum Nextcloud version assigned. This will be an error in the future.')); ?>

{{/if}} {{/if}} diff --git a/settings/templates/personal.php b/settings/templates/personal.php index b4ff5db5c7c..45f61310b30 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -138,7 +138,7 @@ if($_['passwordChangeSupported']) {

t('Sessions'));?>

- t('These are the web, desktop and mobile clients currently logged in to your ownCloud.'));?> + t('These are the web, desktop and mobile clients currently logged in to your account.'));?> @@ -166,7 +166,7 @@ if($_['passwordChangeSupported']) {
-

t('A device password is a passcode that gives an app or device permissions to access your ownCloud account.'));?>

+

t('A device password is a passcode that gives an app or device permissions to access your account.'));?>

@@ -197,7 +197,7 @@ if($_['passwordChangeSupported']) { - + t('Help translate'));?> @@ -223,10 +223,10 @@ if($_['passwordChangeSupported']) {

t('If you want to support the project - join development or - spread the word!'));?>

diff --git a/settings/templates/settings.development.notice.php b/settings/templates/settings.development.notice.php index c88c90f6b6b..2834277cfd6 100644 --- a/settings/templates/settings.development.notice.php +++ b/settings/templates/settings.development.notice.php @@ -8,12 +8,12 @@ '{linkclose}', ], [ - '', + '', '', '', '', ], - $l->t('Developed by the {communityopen}ownCloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') + $l->t('Developed by the {communityopen}Nextcloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') )); ?>

-- cgit v1.2.3 From 2a990a0db5199ac842b50b580300bbeb2d2e794c Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 27 Jun 2016 11:30:13 +0200 Subject: verify user password on change --- lib/private/User/Database.php | 10 ++++++-- settings/ChangePassword/Controller.php | 31 ++++++++++++++-------- settings/js/personal.js | 30 ++++++++++++++-------- settings/templates/personal.php | 3 +-- tests/lib/User/DatabaseTest.php | 47 +++++++++++++++++++++++++++++++++- 5 files changed, 95 insertions(+), 26 deletions(-) (limited to 'settings/templates') diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 1dcac287e1e..85cbddca359 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -51,6 +51,8 @@ namespace OC\User; use OC\Cache\CappedMemoryCache; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\GenericEvent; /** * Class for user management in a SQL Database (e.g. MySQL, SQLite) @@ -58,12 +60,14 @@ use OC\Cache\CappedMemoryCache; class Database extends \OC\User\Backend implements \OCP\IUserBackend { /** @var CappedMemoryCache */ private $cache; - + /** @var EventDispatcher */ + private $eventDispatcher; /** * OC_User_Database constructor. */ - public function __construct() { + public function __construct($eventDispatcher = null) { $this->cache = new CappedMemoryCache(); + $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher(); } /** @@ -115,6 +119,8 @@ class Database extends \OC\User\Backend implements \OCP\IUserBackend { */ public function setPassword($uid, $password) { if ($this->userExists($uid)) { + $event = new GenericEvent($password); + $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?'); $result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid)); diff --git a/settings/ChangePassword/Controller.php b/settings/ChangePassword/Controller.php index 1f3ea1b446a..94fb1e4e7a2 100644 --- a/settings/ChangePassword/Controller.php +++ b/settings/ChangePassword/Controller.php @@ -30,6 +30,8 @@ */ namespace OC\Settings\ChangePassword; +use OC\HintException; + class Controller { public static function changePersonalPassword($args) { // Check if we are an user @@ -39,17 +41,22 @@ class Controller { $username = \OC_User::getUser(); $password = isset($_POST['personal-password']) ? $_POST['personal-password'] : null; $oldPassword = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : ''; + $l = new \OC_L10n('settings'); if (!\OC_User::checkPassword($username, $oldPassword)) { - $l = new \OC_L10n('settings'); \OC_JSON::error(array("data" => array("message" => $l->t("Wrong password")) )); exit(); } - if (!is_null($password) && \OC_User::setPassword($username, $password)) { - \OC::$server->getUserSession()->updateSessionTokenPassword($password); - \OC_JSON::success(); - } else { - \OC_JSON::error(); + + try { + if (!is_null($password) && \OC_User::setPassword($username, $password)) { + \OC::$server->getUserSession()->updateSessionTokenPassword($password); + \OC_JSON::success(['data' => ['message' => $l->t('Saved')]]); + } else { + \OC_JSON::error(); + } + } catch (HintException $e) { + \OC_JSON::error(['data' => ['message' => $e->getHint()]]); } } @@ -150,10 +157,14 @@ class Controller { } } else { // if encryption is disabled, proceed - if (!is_null($password) && \OC_User::setPassword($username, $password)) { - \OC_JSON::success(array('data' => array('username' => $username))); - } else { - \OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password')))); + try { + if (!is_null($password) && \OC_User::setPassword($username, $password)) { + \OC_JSON::success(array('data' => array('username' => $username))); + } else { + \OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password')))); + } + } catch (HintException $e) { + \OC_JSON::error(array('data' => array('message' => $e->getHint()))); } } } diff --git a/settings/js/personal.js b/settings/js/personal.js index c9e575afd6b..16a8d184da6 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -192,6 +192,7 @@ $(document).ready(function () { $('#pass2').showPassword().keyup(); } $("#passwordbutton").click(function () { + OC.msg.startSaving('#password-error-msg'); var isIE8or9 = $('html').hasClass('lte9'); // FIXME - TODO - once support for IE8 and IE9 is dropped // for IE8 and IE9 this will check additionally if the typed in password @@ -208,25 +209,32 @@ $(document).ready(function () { if (data.status === "success") { $('#pass1').val(''); $('#pass2').val('').change(); - // Hide a possible errormsg and show successmsg - $('#password-changed').removeClass('hidden').addClass('inlineblock'); - $('#password-error').removeClass('inlineblock').addClass('hidden'); + OC.msg.finishedSaving('#password-error-msg', data); } else { if (typeof(data.data) !== "undefined") { - $('#password-error').text(data.data.message); + OC.msg.finishedSaving('#password-error-msg', data); } else { - $('#password-error').text(t('Unable to change password')); + OC.msg.finishedSaving('#password-error-msg', + { + 'status' : 'error', + 'data' : { + 'message' : t('core', 'Unable to change password') + } + } + ); } - // Hide a possible successmsg and show errormsg - $('#password-changed').removeClass('inlineblock').addClass('hidden'); - $('#password-error').removeClass('hidden').addClass('inlineblock'); } }); return false; } else { - // Hide a possible successmsg and show errormsg - $('#password-changed').removeClass('inlineblock').addClass('hidden'); - $('#password-error').removeClass('hidden').addClass('inlineblock'); + OC.msg.finishedSaving('#password-error-msg', + { + 'status' : 'error', + 'data' : { + 'message' : t('core', 'Unable to change password') + } + } + ); return false; } diff --git a/settings/templates/personal.php b/settings/templates/personal.php index e86a84dfa08..716570cad84 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -118,8 +118,7 @@ if($_['passwordChangeSupported']) { ?>

t('Password'));?>

- - +
backend=new \OC\User\Database(); + + $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcher'); + + $this->backend=new \OC\User\Database($this->eventDispatcher); } protected function tearDown() { @@ -51,4 +59,41 @@ class DatabaseTest extends Backend { } parent::tearDown(); } + + public function testVerifyPasswordEvent() { + $user = $this->getUser(); + $this->backend->createUser($user, 'pass1'); + + $this->eventDispatcher->expects($this->once())->method('dispatch') + ->willReturnCallback( + function ($eventName, GenericEvent $event) { + $this->assertSame('OCP\PasswordPolicy::validate', $eventName); + $this->assertSame('newpass', $event->getSubject()); + } + ); + + $this->backend->setPassword($user, 'newpass'); + $this->assertSame($user, $this->backend->checkPassword($user, 'newpass')); + } + + /** + * @expectedException \OC\HintException + * @expectedExceptionMessage password change failed + */ + public function testVerifyPasswordEventFail() { + $user = $this->getUser(); + $this->backend->createUser($user, 'pass1'); + + $this->eventDispatcher->expects($this->once())->method('dispatch') + ->willReturnCallback( + function ($eventName, GenericEvent $event) { + $this->assertSame('OCP\PasswordPolicy::validate', $eventName); + $this->assertSame('newpass', $event->getSubject()); + throw new HintException('password change failed', 'password change failed'); + } + ); + + $this->backend->setPassword($user, 'newpass'); + $this->assertSame($user, $this->backend->checkPassword($user, 'newpass')); + } } -- cgit v1.2.3