34 lines
844 B
PHP
34 lines
844 B
PHP
<?php
|
|
|
|
namespace plugin\admin\app\model;
|
|
|
|
use app\model\Base;
|
|
|
|
/**
|
|
* @property integer $id ID(主键)
|
|
* @property string $username 用户名
|
|
* @property string $nickname 昵称
|
|
* @property string $password 密码
|
|
* @property string $avatar 头像
|
|
* @property string $email 邮箱
|
|
* @property string $mobile 手机
|
|
* @property string $totp_secret totp_secret
|
|
* @property string $created_at 创建时间
|
|
* @property string $updated_at 更新时间
|
|
* @property string $login_at 登录时间
|
|
* @property string $roles 角色
|
|
* @property integer $status 状态 0正常 1禁用
|
|
*/
|
|
class Admin extends Base
|
|
{
|
|
public static function onAfterWrite($row)
|
|
{
|
|
if(!$row->totp_secret){
|
|
$totp = \OTPHP\TOTP::create();
|
|
$row->totp_secret = $totp->getSecret();
|
|
$row->save();
|
|
}
|
|
}
|
|
|
|
}
|