Commit 8e1f2852 authored by 杨培's avatar 杨培

登录时更新数据库时间

migrate 增加
parent 7364a947
...@@ -20,6 +20,10 @@ return [ ...@@ -20,6 +20,10 @@ return [
'identityClass' => 'backend\models\User', 'identityClass' => 'backend\models\User',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true], 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
'on afterLogin' => function ($event) {
$event->identity->logged_at = time();
$event->identity->update();
}
], ],
'session' => [ 'session' => [
// this is the name of the session cookie used for login on the backend // this is the name of the session cookie used for login on the backend
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
namespace backend\controllers; namespace backend\controllers;
use backend\models\LoginForm; use backend\models\LoginForm;
use backend\models\User;
use common\libs\Utils;
use Yii; use Yii;
use yii\base\Event;
use yii\web\Controller; use yii\web\Controller;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\User;
/** /**
* Site controller * Site controller
...@@ -82,6 +82,7 @@ class SiteController extends Controller ...@@ -82,6 +82,7 @@ class SiteController extends Controller
} }
$model = new LoginForm(); $model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) { if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack(); return $this->goBack();
} else { } else {
......
...@@ -254,9 +254,9 @@ class Course extends \yii\db\ActiveRecord ...@@ -254,9 +254,9 @@ class Course extends \yii\db\ActiveRecord
return self::find()->where($where)->sum('comment_count'); return self::find()->where($where)->sum('comment_count');
} }
public static function url($courseId, $schema=false) public static function url($courseId)
{ {
return Url::to(['home/video', 'courseId'=>$courseId], $schema); return \Yii::$app->params['baseUrl'].Url::to(['home/video', 'courseId'=>$courseId]);
} }
/** /**
......
...@@ -5,7 +5,7 @@ use yii\db\Migration; ...@@ -5,7 +5,7 @@ use yii\db\Migration;
class m161026_085127_transcode_queue extends Migration class m161026_085127_transcode_queue extends Migration
{ {
public $table = '{{%ranscode_queue}}'; public $table = '{{%transcode_queue}}';
public function up() public function up()
{ {
......
<?php
use yii\db\Migration;
class m161026_111007_admin_users extends Migration
{
public $table = '{{%admin_users}}';
public function up()
{
$this->createTable($this->table, [
'id' => $this->primaryKey(10)->unsigned()->notNull(),
'username' => $this->string(50)->notNull(),
'auth_key' => $this->string(30)->notNull(),
'password_hash' => $this->string(255)->notNull(),
'status' => $this->smallInteger(2)->notNull()->defaultValue(0)->comment('0正常, 1锁定'),
'ip' => $this->string(32)->notNull(),
'created_at' => $this->integer(10)->unsigned()->notNull(),
'updated_at' => $this->integer(10)->unsigned()->notNull(),
'logged_at' => $this->integer(10)->unsigned()->notNull()
]);
$this->addCommentOnTable($this->table, '管理员用户');
$this->createIndex('uesrname', $this->table, 'username', true);
}
public function down()
{
$this->dropTable($this->table);
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment