Commit 7c00f2ef by lujunyi

类型

parent 3b2a9d90
...@@ -22,7 +22,7 @@ public function login(Request $request) ...@@ -22,7 +22,7 @@ public function login(Request $request)
$code = $request->input('code'); $code = $request->input('code');
$credentials = app('wechat.mini_program')->auth->session($code); $credentials = app('wechat.mini_program')->auth->session($code);
if ($credentials['openid'] ?? '') { if ($credentials['openid'] ?? '') {
$user = User::firstOrCreate(['openid', $credentials['openid']]); $user = User::firstOrCreate(['openid' => $credentials['openid']]);
// 追加登录类型到token里面,前端需要带在header头中 Authorization:Bearer Token // 追加登录类型到token里面,前端需要带在header头中 Authorization:Bearer Token
$token = auth('api')->claims(['login_type' => User::LOGIN_TYPE_USER])->fromUser($user); $token = auth('api')->claims(['login_type' => User::LOGIN_TYPE_USER])->fromUser($user);
$data = $this->respondWithToken($token)->original; $data = $this->respondWithToken($token)->original;
......
...@@ -53,9 +53,9 @@ class User extends Authenticatable implements JWTSubject ...@@ -53,9 +53,9 @@ class User extends Authenticatable implements JWTSubject
// 登录类型-文字映射 // 登录类型-文字映射
const LOGIN_TYPE_MAP = [ const LOGIN_TYPE_MAP = [
self::LOGIN_USER => '普通用户', self::LOGIN_TYPE_USER => '普通用户',
self::LOGIN_DOCTOR => '医师', self::LOGIN_TYPE_DOCTOR => '医师',
self::LOGIN_PHARMACIST => '药师', self::LOGIN_TYPE_PHARMACIST => '药师',
]; ];
// 下面是jwt-aut必须要实现的方法 // 下面是jwt-aut必须要实现的方法
......
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