summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2013-02-05 06:32:55 -0800
committerFrank Karlitschek <frank@owncloud.org>2013-02-05 06:32:55 -0800
commit9e18531526a105a109906e3e1c9b5b8b73f811ac (patch)
tree6e623b782d866f3bfd02d15c819ef4c6002c1b4e
parent9bd53842098f66bde0e7ee56f577bcc2cff8ce66 (diff)
parent503a84c2252056c45765811b888f0e6993ae0742 (diff)
downloadnextcloud-server-9e18531526a105a109906e3e1c9b5b8b73f811ac.tar.gz
nextcloud-server-9e18531526a105a109906e3e1c9b5b8b73f811ac.zip
Merge pull request #1467 from owncloud/fix_change_password
offer change password only when the action is supported by the user back...
-rw-r--r--lib/user.php18
-rw-r--r--settings/personal.php1
-rw-r--r--settings/templates/personal.php7
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/user.php b/lib/user.php
index 42116fa9e0c..6cea4ef0cb1 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -345,6 +345,24 @@ class OC_User {
}
/**
+ * @brief Check whether user can change his password
+ * @param $uid The username
+ * @returns true/false
+ *
+ * Check whether a specified user can change his password
+ */
+ public static function canUserChangePassword($uid) {
+ foreach(self::$_usedBackends as $backend) {
+ if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)) {
+ if($backend->userExists($uid)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
* @brief Check if the password is correct
* @param $uid The username
* @param $password The password
diff --git a/settings/personal.php b/settings/personal.php
index 2031edd8df8..fd8a255fa09 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -55,6 +55,7 @@ $tmpl->assign('total_space', OC_Helper::humanFileSize($total));
$tmpl->assign('usage_relative', $relative);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
+$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
$forms=OC_App::getForms('personal');
$tmpl->assign('forms', array());
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 55ff24b4223..59260370865 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -13,7 +13,9 @@
<a class="button" href="http://owncloud.org/sync-clients/" target="_blank"><?php echo $l->t('Download');?></a>
</div>
-
+<?php
+if($_['passwordChangeSupported']) {
+?>
<form id="passwordform">
<fieldset class="personalblock">
<div id="passwordchanged"><?php echo $l->t('Your password was changed');?></div>
@@ -24,6 +26,9 @@
<input id="passwordbutton" type="submit" value="<?php echo $l->t('Change password');?>" />
</fieldset>
</form>
+<?php
+}
+?>
<form id="lostpassword">
<fieldset class="personalblock">