mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Don't allow guest user to change or reset password
This commit is contained in:
parent
64eacd6f76
commit
0bb2c9f70c
@ -13,15 +13,22 @@
|
|||||||
|
|
||||||
if (!count((array)$err)) {
|
if (!count((array)$err)) {
|
||||||
$username = $frm->username;
|
$username = $frm->username;
|
||||||
$password = $frm->newpassword1;
|
$password = md5($frm->newpassword1);
|
||||||
|
|
||||||
if (! set_field("user", "password", md5($frm->newpassword1), "username", $frm->username)) {
|
$user = get_user_info_from_db("username", $username);
|
||||||
|
|
||||||
|
if (isguest($user->id)) {
|
||||||
|
error("Can't change guest password!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set_field("user", "password", $password, "username", $username)) {
|
||||||
|
$user->password = $password;
|
||||||
|
} else {
|
||||||
error("Could not set the new password");
|
error("Could not set the new password");
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($USER);
|
unset($USER);
|
||||||
|
$USER = $user;
|
||||||
$USER = get_user_info_from_db("username", $username);
|
|
||||||
$USER->loggedin = true;
|
$USER->loggedin = true;
|
||||||
|
|
||||||
set_moodle_cookie($USER->username);
|
set_moodle_cookie($USER->username);
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
error("No such user with this address: $frm->email");
|
error("No such user with this address: $frm->email");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isguest($user->id)) {
|
||||||
|
error("Can't change guest password!");
|
||||||
|
}
|
||||||
|
|
||||||
if (! reset_password_and_mail($user)) {
|
if (! reset_password_and_mail($user)) {
|
||||||
error("Could not reset password and mail the new one to you");
|
error("Could not reset password and mail the new one to you");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user