Commit 16bd4045 by lujunyi

修改用户表

parent 723e7713
......@@ -23,7 +23,7 @@ public function login(Request $request)
$credentials = app('wechat.mini_program')->auth->session($code);
if ($credentials['openid'] ?? '') {
$user = User::firstOrCreate(['miniapp_openid', $credentials['openid']]);
$token = auth('api')->claims(['role' => '问诊人'])->fromUser($user);
$token = auth('api')->claims(['login_type' => User::LOGIN_TYPE_USER])->fromUser($user);
// $data = $this->respondWithToken($token)->original;
$data = ['token' => $token];
......
......@@ -44,6 +44,20 @@ class User extends Authenticatable implements JWTSubject
'password' => 'hashed',
];
// 登录类型[0=普通用户,1=医师,2=药师]
const LOGIN_TYPE_USER = 0;
const LOGIN_TYPE_DOCTOR = 1;
const LOGIN_TYPE_PHARMACIST = 2;
// 登录类型-文字映射
const LOGIN_TYPE_MAP = [
self::LOGIN_USER => '普通用户',
self::LOGIN_DOCTOR => '医师',
self::LOGIN_PHARMACIST => '药师',
];
// 下面是jwt-aut必须要实现的方法
/**
* Get the identifier that will be stored in the subject claim of the JWT.
......
......@@ -13,11 +13,16 @@ public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('name')->nullable();
$table->string('email')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('password')->nullable();
$table->rememberToken();
$table->string('openid', 40)->nullable()->unique('uk_openid')->comment('小程序openid');
$table->string('avatar')->nullable()->comment('头像');
$table->string('nick_name', 100)->nullable()->comment('昵称');
$table->tinyInteger('last_login_type')->default(0)->comment('最后一次登录类型[0=普通用户,1=医师,2=药师]');
$table->timestamps();
});
}
......
......@@ -18,9 +18,6 @@ public function up(): void
$table->tinyInteger('gender')->default(0)->comment('性别。[1=男性,2=女性,0=未知]');
$table->string('id_card', 18)->nullable()->index('idx_idcard')->comment('身份证号');
$table->string('mobile', 11)->nullable()->index('idx_mobile')->comment('手机号');
$table->string('miniapp_openid', 40)->nullable()->index('idx_miniappopenid')->comment('小程序openid');
$table->string('avatar')->nullable()->comment('头像');
$table->string('nick_name', 100)->nullable()->comment('昵称');
$table->timestamps();
$table->softDeletes();
});
......
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 sign in to comment