Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨昕
media-resource
Commits
c95fbab9
Commit
c95fbab9
authored
May 21, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化获取token接口
parent
bb2f471b
Pipeline
#14732
passed with stages
in 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
Apprialisal.php
app/Http/Middleware/Apprialisal.php
+13
-11
No files found.
app/Http/Middleware/Apprialisal.php
View file @
c95fbab9
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Middleware
;
use
App\Model\LogModel
;
use
Closure
;
use
Carbon\Carbon
;
use
App\Exceptions\ControllerException
;
...
...
@@ -30,31 +31,32 @@ class Apprialisal
}
$token
=
substr
(
$headers
[
'authorization'
][
0
],
7
);
$user
=
DB
::
connection
(
'mongodb'
)
->
collection
(
"users"
)
->
where
(
"token"
,
$token
)
->
first
();
if
(
empty
(
$user
)){
return
error
(
"请求异常:Authorization不存在"
,
1014
);
}
try
{
$params
=
decrypt
(
$token
);
decrypt
(
$token
);
}
catch
(
DecryptException
$e
)
{
return
error
(
'token非法'
);
}
$user
=
DB
::
connection
(
'mongodb'
)
->
collection
(
"users"
)
->
where
(
"token"
,
$token
)
->
first
();
if
(
empty
(
$user
)){
return
error
(
"请求异常:Authorization不存在"
,
1014
);
}
$idArr
=
(
$user
[
'_id'
])
->
jsonSerialize
();
$_id
=
$idArr
[
'$oid'
];
try
{
$idArr
=
(
$user
[
'_id'
])
->
jsonSerialize
();
}
catch
(
\Exception
$e
){
LogModel
::
addlog
([
'获取用户数据异常'
=>
$request
->
all
()]);
return
error
(
"获取用户数据异常,请重新登录再试!"
,
1015
);
}
$request
->
replace
(
array_merge
(
$request
->
all
(),
[
'access_token'
=>
substr
(
$headers
[
'authorization'
][
0
],
7
),
'token_username'
=>
$user
[
'name'
],
'token_user_id'
=>
$
_id
,
'token_user_id'
=>
$
idArr
[
'$oid'
]
,
'mis_uid'
=>
$user
[
'mis_uid'
]
]));
return
$next
(
$request
);
}
}
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