Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7c00f2ef
authored
Nov 12, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
类型
parent
3b2a9d90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
app/Api/Controllers/UserController.php
+1
-1
app/Models/User.php
+3
-3
No files found.
app/Api/Controllers/UserController.php
View file @
7c00f2ef
...
@@ -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
;
...
...
app/Models/User.php
View file @
7c00f2ef
...
@@ -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必须要实现的方法
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment