Save users last login datetime

This commit is contained in:
Lucas Bartholemy 2014-07-06 15:57:21 +02:00
parent fc5b8e2408
commit 01e51593bb
2 changed files with 31 additions and 0 deletions

View File

@ -107,6 +107,10 @@ class UserIdentity extends CUserIdentity {
* @param User $user
*/
private function onSuccessfulAuthenticate($user) {
$user->last_login = new CDbExpression('NOW()');
$user->save();
$this->_id = $user->id;
$this->setState('title', $user->title);
}

View File

@ -0,0 +1,27 @@
<?php
class m140706_135210_lastlogin extends EDbMigration
{
public function up()
{
$this->addColumn('user', 'last_login', 'DATETIME DEFAULT NULL');
}
public function down()
{
echo "m140706_135210_lastlogin does not support migration down.\n";
return false;
}
/*
// Use safeUp/safeDown to do migration with transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}