Merge pull request #1369 from TheSerapher/issue-1162
[ADDED] last_login timestamp
This commit is contained in:
commit
28fffefa94
@ -238,7 +238,7 @@ class Base {
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param($field['type'].'i', $field['value'], $id) && $stmt->execute())
|
||||
return true;
|
||||
$this->debug->append("Unable to update " . $field['name'] . " with " . $field['value'] . " for ID $id");
|
||||
$this->sqlError();
|
||||
return $this->sqlError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -128,6 +128,7 @@ class User extends Base {
|
||||
return false;
|
||||
}
|
||||
if ($this->checkUserPassword($username, $password)) {
|
||||
$this->updateLoginTimestamp($this->getUserId($username));
|
||||
$this->createSession($username);
|
||||
if ($this->setUserIp($this->getUserId($username), $_SERVER['REMOTE_ADDR']))
|
||||
return true;
|
||||
@ -407,6 +408,16 @@ class User extends Base {
|
||||
$_SESSION['USERDATA'] = $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update users last_login timestamp
|
||||
* @param id int UserID
|
||||
* @return bool true of false
|
||||
**/
|
||||
private function updateLoginTimestamp($id) {
|
||||
$field = array('name' => 'last_login', 'type' => 'i', 'value' => time());
|
||||
return $this->updateSingle($id, $field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out current user, destroy the session
|
||||
* @param none
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
define('DB_VERSION', '0.0.1');
|
||||
define('DB_VERSION', '0.0.2');
|
||||
define('CONFIG_VERSION', '0.0.2');
|
||||
define('MPOS_VERSION', '0.0.1');
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS `accounts` (
|
||||
`is_locked` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`failed_logins` int(5) unsigned DEFAULT '0',
|
||||
`failed_pins` int(5) unsigned DEFAULT '0',
|
||||
`sessionTimeoutStamp` int(255) DEFAULT NULL,
|
||||
`last_login` int(10) DEFAULT NULL,
|
||||
`pin` varchar(255) NOT NULL COMMENT 'four digit pin to allow account changes',
|
||||
`api_key` varchar(255) DEFAULT NULL,
|
||||
`token` varchar(65) DEFAULT NULL,
|
||||
|
||||
3
sql/012_accounts_update.sql
Normal file
3
sql/012_accounts_update.sql
Normal file
@ -0,0 +1,3 @@
|
||||
ALTER TABLE `accounts` CHANGE `sessionTimeoutStamp` `last_login` INT( 10 ) NULL DEFAULT NULL ;
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('DB_VERSION', '0.0.2') ON DUPLICATE KEY UPDATE `value` = '0.0.2';
|
||||
INSERT INTO `settings` (`name`, `value`) VALUES ('db_upgrade_required', 0) ON DUPLICATE KEY UPDATE `value` = 0;
|
||||
Loading…
Reference in New Issue
Block a user