mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-42097-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
commit
8761a4f15d
@ -664,7 +664,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
* @return moodle_url
|
||||
*/
|
||||
function change_password_url() {
|
||||
if ($this->is_internal()) {
|
||||
if ($this->is_internal() || empty($this->config->changepasswordurl)) {
|
||||
// Standard form.
|
||||
return null;
|
||||
} else {
|
||||
|
@ -120,7 +120,11 @@ class auth_plugin_imap extends auth_plugin_base {
|
||||
* @return moodle_url
|
||||
*/
|
||||
function change_password_url() {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
if (!empty($this->config->changepasswordurl)) {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1603,7 +1603,11 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
*/
|
||||
function change_password_url() {
|
||||
if (empty($this->config->stdchangepassword)) {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
if (!empty($this->config->changepasswordurl)) {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -120,7 +120,11 @@ class auth_plugin_pop3 extends auth_plugin_base {
|
||||
* @return moodle_url
|
||||
*/
|
||||
function change_password_url() {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
if (!empty($this->config->changepasswordurl)) {
|
||||
return new moodle_url($this->config->changepasswordurl);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,10 @@
|
||||
This files describes API changes in /auth/* - plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 2.7 ===
|
||||
|
||||
* If you are returning a url in method change_password_url() from config, please make sure it is set before trying to use it.
|
||||
|
||||
=== 2.6 ===
|
||||
|
||||
* can_be_manually_set() - This function was introduced in the base class and returns false by default. If overriden by
|
||||
|
@ -159,6 +159,8 @@ class auth_plugin_base {
|
||||
*
|
||||
* This method is used if can_change_password() returns true.
|
||||
* This method is called only when user is logged in, it may use global $USER.
|
||||
* If you are using a plugin config variable in this method, please make sure it is set before using it,
|
||||
* as this method can be called even if the plugin is disabled, in which case the config values won't be set.
|
||||
*
|
||||
* @return moodle_url url of the profile page or null if standard used
|
||||
*/
|
||||
|
@ -399,6 +399,72 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||
hide : false
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Lock the given field if the field value is in the given set of values.
|
||||
*
|
||||
* @param elements
|
||||
* @param values
|
||||
* @returns {{lock: boolean, hide: boolean}}
|
||||
* @private
|
||||
*/
|
||||
_dependency_in : function(elements, values) {
|
||||
// A pipe (|) is used as a value separator
|
||||
// when multiple values have to be passed on at the same time.
|
||||
values = values.split('|');
|
||||
var lock = false;
|
||||
var hidden_val = false;
|
||||
var options, v, selected, value;
|
||||
elements.each(function(){
|
||||
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'hidden' && !this.siblings('input[type=checkbox][name="' + this.get('name') + '"]').isEmpty()) {
|
||||
// This is the hidden input that is part of an advcheckbox.
|
||||
hidden_val = (values.indexOf(this.get('value')) > -1);
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'checkbox' && !Y.Node.getDOMNode(this).checked) {
|
||||
lock = lock || hidden_val;
|
||||
return;
|
||||
}
|
||||
if (this.getAttribute('class').toLowerCase() == 'filepickerhidden') {
|
||||
// Check for filepicker status.
|
||||
var elementname = this.getAttribute('name');
|
||||
if (elementname && M.form_filepicker.instances[elementname].fileadded) {
|
||||
lock = false;
|
||||
} else {
|
||||
lock = true;
|
||||
}
|
||||
} else if (this.get('nodeName').toUpperCase() === 'SELECT' && this.get('multiple') === true) {
|
||||
// Multiple selects can have one or more value assigned.
|
||||
selected = [];
|
||||
options = this.get('options');
|
||||
options.each(function() {
|
||||
if (this.get('selected')) {
|
||||
selected[selected.length] = this.get('value');
|
||||
}
|
||||
});
|
||||
if (selected.length > 0 && selected.length === values.length) {
|
||||
for (var i in selected) {
|
||||
v = selected[i];
|
||||
if (values.indexOf(v) > -1) {
|
||||
lock = true;
|
||||
} else {
|
||||
lock = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lock = false;
|
||||
}
|
||||
} else {
|
||||
value = this.get('value');
|
||||
lock = lock || (values.indexOf(value) > -1);
|
||||
}
|
||||
});
|
||||
return {
|
||||
lock : lock,
|
||||
hide : false
|
||||
}
|
||||
},
|
||||
_dependency_hide : function(elements, value) {
|
||||
return {
|
||||
lock : false,
|
||||
|
@ -50,7 +50,13 @@ class user_editadvanced_form extends moodleform {
|
||||
$enabled = get_string('pluginenabled', 'core_plugin');
|
||||
$disabled = get_string('plugindisabled', 'core_plugin');
|
||||
$auth_options = array($enabled=>array(), $disabled=>array());
|
||||
$cannotchangepass = array();
|
||||
foreach ($auths as $auth => $unused) {
|
||||
$authinst = get_auth_plugin($auth);
|
||||
$passwordurl = $authinst->change_password_url();
|
||||
if (!($authinst->can_change_password() && empty($passwordurl))) {
|
||||
$cannotchangepass[] = $auth;
|
||||
}
|
||||
if (is_enabled_auth($auth)) {
|
||||
$auth_options[$enabled][$auth] = get_string('pluginname', "auth_{$auth}");
|
||||
} else {
|
||||
@ -73,6 +79,8 @@ class user_editadvanced_form extends moodleform {
|
||||
$mform->setType('newpassword', PARAM_RAW);
|
||||
$mform->disabledIf('newpassword', 'createpassword', 'checked');
|
||||
|
||||
$mform->disabledIf('newpassword', 'auth', 'in', $cannotchangepass);
|
||||
|
||||
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
|
||||
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
|
||||
$mform->disabledIf('preference_auth_forcepasswordchange', 'createpassword', 'checked');
|
||||
|
19
user/tests/behat/edituserpassword.feature
Normal file
19
user/tests/behat/edituserpassword.feature
Normal file
@ -0,0 +1,19 @@
|
||||
@core @core_user
|
||||
Feature: Enable/disable password field based on authentication selected.
|
||||
In order edit a user password properly
|
||||
As an admin
|
||||
I need to be able to notice if the change in password is allowed by athuentication plugin or not
|
||||
|
||||
@javascript
|
||||
Scenario: Verify the password field is enabled/disabled based on authentication selected, in user edit advanced page.
|
||||
Given I log in as "admin"
|
||||
And I follow "My home"
|
||||
And I expand "Site administration" node
|
||||
And I expand "Users" node
|
||||
And I expand "Accounts" node
|
||||
When I follow "Add a new user"
|
||||
Then the "newpassword" "field" should be enabled
|
||||
And I select "Web services authentication" from "auth"
|
||||
And the "newpassword" "field" should be disabled
|
||||
And I select "Email-based self-registration" from "auth"
|
||||
And the "newpassword" "field" should be enabled
|
Loading…
x
Reference in New Issue
Block a user