mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
mod/chat - cope with missing $USER->lastIP
$USER->lastIP is sometimes not set properly during login, fetch it if we can or error out clearly -- we won't be able to login the user to the chat if we don't have an IP address to match him/her against.
This commit is contained in:
parent
9977aa0f4a
commit
d13ef2fbdc
@ -385,6 +385,16 @@ function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
$chatuser->lastping = time();
|
||||
$chatuser->lang = current_language();
|
||||
|
||||
// Sometimes $USER->lastIP is not setup properly
|
||||
// during login. Update with current value if possible
|
||||
// or error out clearly.
|
||||
if (empty($chatuser->ip)) {
|
||||
$chatuser->ip = getremoteaddr();
|
||||
if (empty($chatuser->ip)) {
|
||||
error("Cannot determine the IP address of the user!");
|
||||
}
|
||||
}
|
||||
|
||||
if (($chatuser->course != $course->id)
|
||||
or ($chatuser->userid != $USER->id)) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user