mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-28 17:43:54 -07:00
Add last_login column to user table and populate upon login
This commit is contained in:
parent
0f4dc18074
commit
bb0b626cee
6 changed files with 22 additions and 2 deletions
5
servatrice/migrations/servatrice_0005_to_0006.sql
Normal file
5
servatrice/migrations/servatrice_0005_to_0006.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- Servatrice db migration from version 5 to version 6
|
||||
|
||||
alter table cockatrice_users add last_login datetime not null;
|
||||
|
||||
UPDATE cockatrice_schema_version SET version=6 WHERE version=5;
|
||||
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
|||
PRIMARY KEY (`version`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO cockatrice_schema_version VALUES(5);
|
||||
INSERT INTO cockatrice_schema_version VALUES(6);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
||||
`id` int(7) unsigned zerofill NOT NULL auto_increment,
|
||||
|
|
@ -84,6 +84,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
|||
`active` tinyint(1) NOT NULL,
|
||||
`token` binary(16) NOT NULL,
|
||||
`clientid` varchar(15) NOT NULL,
|
||||
`last_login` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
KEY `token` (`token`),
|
||||
|
|
|
|||
|
|
@ -880,3 +880,14 @@ void Servatrice_DatabaseInterface::updateUsersClientID(const QString &userName,
|
|||
execSqlQuery(query);
|
||||
|
||||
}
|
||||
|
||||
void Servatrice_DatabaseInterface::updateUsersLastLoginTime(const QString &userName)
|
||||
{
|
||||
if (!checkSql())
|
||||
return;
|
||||
|
||||
QSqlQuery *query = prepareQuery("update {prefix}_users set last_login = NOW() where name = :user_name");
|
||||
query->bindValue(":user_name", userName);
|
||||
execSqlQuery(query);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "server.h"
|
||||
#include "server_database_interface.h"
|
||||
|
||||
#define DATABASE_SCHEMA_VERSION 5
|
||||
#define DATABASE_SCHEMA_VERSION 6
|
||||
|
||||
class Servatrice;
|
||||
|
||||
|
|
@ -73,6 +73,7 @@ public:
|
|||
const QString &password, const QString &emailAddress, const QString &country, QString &token, bool active = false);
|
||||
bool activateUser(const QString &userName, const QString &token);
|
||||
void updateUsersClientID(const QString &userName, const QString &userClientID);
|
||||
void updateUsersLastLoginTime(const QString &userName);
|
||||
void logMessage(const int senderId, const QString &senderName, const QString &senderIp, const QString &logMessage,
|
||||
LogMessage_TargetType targetType, const int targetId, const QString &targetName);
|
||||
bool changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue