mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-8590 auth cleanup - part 7 and MDL-8598
This commit is contained in:
parent
430759a5fe
commit
9696bd8966
4 changed files with 84 additions and 23 deletions
|
@ -312,6 +312,8 @@ $string['guestloginbutton'] = 'Guest login button';
|
||||||
$string['instructions'] = 'Instructions';
|
$string['instructions'] = 'Instructions';
|
||||||
$string['internal'] = 'Internal';
|
$string['internal'] = 'Internal';
|
||||||
$string['md5'] = 'MD5 hash';
|
$string['md5'] = 'MD5 hash';
|
||||||
|
$string['nopasswordchange'] = 'Password can not be changed';
|
||||||
|
$string['nopasswordchangeforced'] ='You cannot proceed without changing your password, however there is no available page for changing it. Please contact your Moodle Administrator.';
|
||||||
$string['passwordhandling'] = 'Password field handling';
|
$string['passwordhandling'] = 'Password field handling';
|
||||||
$string['plaintext'] = 'Plain text';
|
$string['plaintext'] = 'Plain text';
|
||||||
$string['selfregistration'] = 'Self registration';
|
$string['selfregistration'] = 'Self registration';
|
||||||
|
|
|
@ -484,6 +484,31 @@ If you continue to have difficulty, please contact the site administrator.</p>';
|
||||||
$string['emailpasswordconfirmsent'] = 'An email should have been sent to your address at <b>$a</b>.
|
$string['emailpasswordconfirmsent'] = 'An email should have been sent to your address at <b>$a</b>.
|
||||||
<br />It contains easy instructions to confirm and complete this password change.
|
<br />It contains easy instructions to confirm and complete this password change.
|
||||||
If you continue to have difficulty, contact the site administrator.';
|
If you continue to have difficulty, contact the site administrator.';
|
||||||
|
$string['emailpasswordchangeinfo'] = 'Hi $a->firstname,
|
||||||
|
|
||||||
|
Someone (probably you) has requested a new password for your
|
||||||
|
account on \'$a->sitename\'.
|
||||||
|
|
||||||
|
To change your password, please go to the following web address:
|
||||||
|
|
||||||
|
$a->link
|
||||||
|
|
||||||
|
In most mail programs, this should appear as a blue link
|
||||||
|
which you can just click on. If that doesn\'t work,
|
||||||
|
then cut and paste the address into the address
|
||||||
|
line at the top of your web browser window.
|
||||||
|
|
||||||
|
If you need help, please contact the site administrator,
|
||||||
|
$a->admin';
|
||||||
|
$string['emailpasswordchangeinfofail'] = 'Hi $a->firstname,
|
||||||
|
|
||||||
|
Someone (probably you) has requested a new password for your
|
||||||
|
account on \'$a->sitename\'.
|
||||||
|
|
||||||
|
Unfortunately passwords can not be reset on this site,
|
||||||
|
please contact the site administrator,
|
||||||
|
$a->admin';
|
||||||
|
$string['emailpasswordchangeinfosubject'] = '$a: Change password information';
|
||||||
$string['emailpasswordsent'] = 'Thank you for confirming the change of password.
|
$string['emailpasswordsent'] = 'Thank you for confirming the change of password.
|
||||||
An email containing your new password has been sent to your address at<br /><b>$a->email</b>.<br />
|
An email containing your new password has been sent to your address at<br /><b>$a->email</b>.<br />
|
||||||
The new password was automatically generated - you might like to
|
The new password was automatically generated - you might like to
|
||||||
|
|
|
@ -138,9 +138,6 @@ function xmldb_main_upgrade($oldversion=0) {
|
||||||
if (strpos($k, 'auth_') !== 0) {
|
if (strpos($k, 'auth_') !== 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($k == 'auth_instructions') {
|
|
||||||
continue; //keep as global auth option
|
|
||||||
}
|
|
||||||
$authsetting = substr($k, 5);
|
$authsetting = substr($k, 5);
|
||||||
foreach ($authplugins as $auth) {
|
foreach ($authplugins as $auth) {
|
||||||
if (strpos($authsetting, $auth) !== 0) {
|
if (strpos($authsetting, $auth) !== 0) {
|
||||||
|
|
|
@ -1655,18 +1655,20 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) {
|
||||||
if (!empty($USER->preference['auth_forcepasswordchange']) && empty($USER->realuser)) {
|
if (!empty($USER->preference['auth_forcepasswordchange']) && empty($USER->realuser)) {
|
||||||
if ($userauth->can_change_password()) {
|
if ($userauth->can_change_password()) {
|
||||||
$SESSION->wantsurl = $FULLME;
|
$SESSION->wantsurl = $FULLME;
|
||||||
|
if (method_exists($userauth, 'change_password_url') and $userauth->change_password_url()) {
|
||||||
|
//use plugin custom url
|
||||||
|
redirect($userauth->change_password_url());
|
||||||
|
} else {
|
||||||
|
//use moodle internal method
|
||||||
if (empty($CFG->loginhttps)) {
|
if (empty($CFG->loginhttps)) {
|
||||||
redirect($CFG->wwwroot .'/login/change_password.php');
|
redirect($CFG->wwwroot .'/login/change_password.php');
|
||||||
} else {
|
} else {
|
||||||
$wwwroot = str_replace('http:','https:', $CFG->wwwroot);
|
$wwwroot = str_replace('http:','https:', $CFG->wwwroot);
|
||||||
redirect($wwwroot .'/login/change_password.php');
|
redirect($wwwroot .'/login/change_password.php');
|
||||||
}
|
}
|
||||||
} else if($userauth->change_password_url()) {
|
}
|
||||||
redirect($userauth->change_password_url());
|
|
||||||
} else {
|
} else {
|
||||||
error('You cannot proceed without changing your password.
|
error(get_strin('nopasswordchangeforced', 'auth'));
|
||||||
However there is no available page for changing it.
|
|
||||||
Please contact your Moodle Administrator.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2376,18 +2378,12 @@ function is_enabled_auth($auth) {
|
||||||
* Returns an authentication plugin instance.
|
* Returns an authentication plugin instance.
|
||||||
*
|
*
|
||||||
* @uses $CFG
|
* @uses $CFG
|
||||||
* @param string $auth Form of authentication required. Defaults to the
|
* @param string $auth name of authentication plugin
|
||||||
* global setting in {@link $CFG}.
|
|
||||||
* @return object An instance of the required authentication plugin.
|
* @return object An instance of the required authentication plugin.
|
||||||
*/
|
*/
|
||||||
function get_auth_plugin($auth = '') {
|
function get_auth_plugin($auth) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
// use the manual if not specified
|
|
||||||
if (empty($auth)) {
|
|
||||||
$auth = 'manual';
|
|
||||||
}
|
|
||||||
|
|
||||||
// check the plugin exists first
|
// check the plugin exists first
|
||||||
if (! exists_auth_plugin($auth)) {
|
if (! exists_auth_plugin($auth)) {
|
||||||
error("Authentication plugin '$auth' not found.");
|
error("Authentication plugin '$auth' not found.");
|
||||||
|
@ -2406,7 +2402,6 @@ function get_auth_plugin($auth = '') {
|
||||||
* @uses $CFG
|
* @uses $CFG
|
||||||
* @param string $auth Form of authentication required
|
* @param string $auth Form of authentication required
|
||||||
* @return bool
|
* @return bool
|
||||||
* @todo Outline auth types and provide code example
|
|
||||||
*/
|
*/
|
||||||
function is_internal_auth($auth) {
|
function is_internal_auth($auth) {
|
||||||
$authplugin = get_auth_plugin($auth); // throws error if bad $auth
|
$authplugin = get_auth_plugin($auth); // throws error if bad $auth
|
||||||
|
@ -3568,6 +3563,48 @@ function send_password_change_confirmation_email($user) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* send_password_change_info.
|
||||||
|
*
|
||||||
|
* @uses $CFG
|
||||||
|
* @param user $user A {@link $USER} object
|
||||||
|
* @return bool|string Returns "true" if mail was sent OK, "emailstop" if email
|
||||||
|
* was blocked by user and "false" if there was another sort of error.
|
||||||
|
*/
|
||||||
|
function send_password_change_info($user) {
|
||||||
|
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
$site = get_site();
|
||||||
|
$from = get_admin();
|
||||||
|
|
||||||
|
$data = new object();
|
||||||
|
$data->firstname = $user->firstname;
|
||||||
|
$data->sitename = $site->fullname;
|
||||||
|
$data->admin = fullname($from).' ('. $from->email .')';
|
||||||
|
|
||||||
|
$userauth = get_auth_plugin($user->auth);
|
||||||
|
if ($userauth->can_change_password() and method_exists($userauth, 'change_password_url') and $userauth->change_password_url()) {
|
||||||
|
// we have some external url for password cahnging
|
||||||
|
$data->link .= $userauth->change_password_url();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//no way to change password, sorry
|
||||||
|
$data->link = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data->link)) {
|
||||||
|
$message = get_string('emailpasswordchangeinfo', '', $data);
|
||||||
|
$subject = get_string('emailpasswordchangeinfosubject', '', $site->fullname);
|
||||||
|
} else {
|
||||||
|
$message = get_string('emailpasswordchangeinfofail', '', $data);
|
||||||
|
$subject = get_string('emailpasswordchangeinfosubject', '', $site->fullname);
|
||||||
|
}
|
||||||
|
|
||||||
|
return email_to_user($user, $from, $subject, $message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that an email is allowed. It returns an error message if there
|
* Check that an email is allowed. It returns an error message if there
|
||||||
* was a problem.
|
* was a problem.
|
||||||
|
@ -4051,8 +4088,8 @@ function clean_filename($string) {
|
||||||
function current_language() {
|
function current_language() {
|
||||||
global $CFG, $USER, $SESSION, $COURSE;
|
global $CFG, $USER, $SESSION, $COURSE;
|
||||||
|
|
||||||
if (!empty($OURSE->lang)) { // Course language can override all other settings for this page
|
if ($COURSE->id != SITEID and !empty($COURSE->lang)) { // Course language can override all other settings for this page
|
||||||
$return = $OURSE->lang;
|
$return = $COURSE->lang;
|
||||||
|
|
||||||
} else if (!empty($SESSION->lang)) { // Session language can override other settings
|
} else if (!empty($SESSION->lang)) { // Session language can override other settings
|
||||||
$return = $SESSION->lang;
|
$return = $SESSION->lang;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue