Enforce session logout if IP address changed

Fixes #179
This commit is contained in:
Sebastian Grewe 2013-06-13 13:59:45 +02:00
parent 82155b6f72
commit bfaa0a67ef

View File

@ -44,6 +44,9 @@ class User {
public function getUserToken($id) { public function getUserToken($id) {
return $this->getSingle($id, 'token', 'id'); return $this->getSingle($id, 'token', 'id');
} }
public function getUserIp($id) {
return $this->getSingle($id, 'loggedIp', 'id');
}
public function getIdFromToken($token) { public function getIdFromToken($token) {
return $this->getSingle($token, 'id', 'token', 's'); return $this->getSingle($token, 'id', 'token', 's');
} }
@ -546,7 +549,7 @@ class User {
**/ **/
public function isAuthenticated() { public function isAuthenticated() {
$this->debug->append("STA " . __METHOD__, 4); $this->debug->append("STA " . __METHOD__, 4);
if ($_SESSION['AUTHENTICATED'] == true && ! $this->isLocked($_SESSION['USERDATA']['id'])) if ($_SESSION['AUTHENTICATED'] == true && ! $this->isLocked($_SESSION['USERDATA']['id']) && $this->getUserIp($_SESSION['USERDATA']['id']) == $_SERVER['REMOTE_ADDR'])
return true; return true;
// Catchall // Catchall
$this->logoutUser(); $this->logoutUser();