24小时内连续登录失败3次则封禁账号

dev
Jing Li 2023-12-04 17:24:00 +08:00
parent 91f7b524fe
commit fac1dbdb63
3 changed files with 61 additions and 2 deletions

View File

@ -10,6 +10,10 @@ class AdminUser extends BaseAdminModel
{
use HasApiTokens, Filterable;
protected $casts = [
'banned_at' => 'datetime',
];
protected $fillable = [
'name',
'username',
@ -20,6 +24,8 @@ class AdminUser extends BaseAdminModel
'status',
'is_enable',
'view_all_bases',
'banned_reason',
'banned_at',
];
protected $hidden = [

View File

@ -6,6 +6,16 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function getConnection()
{
return $this->config('database.connection') ?: config('database.default');
}
public function config($key)
{
return config('admin.'.$key);
}
/**
* Run the migrations.
*
@ -13,7 +23,7 @@ return new class extends Migration
*/
public function up()
{
Schema::table('admin_users', function (Blueprint $table) {
Schema::table($this->config('database.users_table'), function (Blueprint $table) {
$table->boolean('view_all_bases')->default(false)->comment('是否可查看所有基地');
});
}
@ -25,7 +35,7 @@ return new class extends Migration
*/
public function down()
{
Schema::table('admin_users', function (Blueprint $table) {
Schema::table($this->config('database.users_table'), function (Blueprint $table) {
$table->dropColumn(['view_all_bases']);
});
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function getConnection()
{
return $this->config('database.connection') ?: config('database.default');
}
public function config($key)
{
return config('admin.'.$key);
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table($this->config('database.users_table'), function (Blueprint $table) {
$table->string('banned_reason')->nullable()->comment('封禁原因');
$table->timestamp('banned_at')->nullable()->comment('封禁时间');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table($this->config('database.users_table'), function (Blueprint $table) {
$table->timestamp(['banned_reason', 'banned_at']);
});
}
};