Merge pull request #178 from TheSerapher/issue-177

Store Users IP address in accounts after login
This commit is contained in:
Sebastian Grewe 2013-06-13 04:47:34 -07:00
commit 25007f3b24

View File

@ -69,7 +69,6 @@ class User {
); );
return $this->updateSingle($id, $field); return $this->updateSingle($id, $field);
} }
public function setUserToken($id) { public function setUserToken($id) {
$field = array( $field = array(
'name' => 'token', 'name' => 'token',
@ -78,6 +77,10 @@ class User {
); );
return $this->updateSingle($id, $field); return $this->updateSingle($id, $field);
} }
private function setUserIp($id, $ip) {
$field = array( 'name' => 'loggedIp', 'type' => 's', 'value' => $ip );
return $this->updateSingle($id, $field);
}
/** /**
* Fetch all users for administrative tasks * Fetch all users for administrative tasks
@ -106,6 +109,7 @@ class User {
} }
if ( $this->checkUserPassword($username, $password)) { if ( $this->checkUserPassword($username, $password)) {
$this->createSession($username); $this->createSession($username);
$this->setUserIp($this->getUserId($username), $_SERVER['REMOTE_ADDR']);
return true; return true;
} }
$this->setErrorMessage("Invalid username or password"); $this->setErrorMessage("Invalid username or password");