Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
laravel-adminpanel
Commits
8114de50
Commit
8114de50
authored
Mar 09, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes for cutom tocken validation
parent
327ad995
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Handler.php
app/Exceptions/Handler.php
+30
-0
No files found.
app/Exceptions/Handler.php
View file @
8114de50
...
...
@@ -51,6 +51,35 @@ class Handler extends ExceptionHandler
* Redirect if token mismatch error
* Usually because user stayed on the same screen too long and their session expired
*/
if
(
$exception
instanceof
\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
)
{
switch
(
get_class
(
$exception
->
getPrevious
()))
{
case
\App\Exceptions\Handler
::
class
:
return
response
()
->
json
([
'status'
=>
'error'
,
'error'
=>
'Token has not been provided'
,
'data'
=>
json_decode
(
"{}"
),
],
$exception
->
getStatusCode
());
case
\Tymon\JWTAuth\Exceptions\TokenExpiredException
::
class
:
return
response
()
->
json
([
'status'
=>
'error'
,
'message'
=>
'Token has expired'
,
'data'
=>
json_decode
(
"{}"
),
],
$exception
->
getStatusCode
());
case
\Tymon\JWTAuth\Exceptions\TokenInvalidException
::
class
:
case
\Tymon\JWTAuth\Exceptions\TokenBlacklistedException
::
class
:
return
response
()
->
json
([
'status'
=>
'error'
,
'message'
=>
'Token is invalid'
,
'data'
=>
json_decode
(
"{}"
),
],
$exception
->
getStatusCode
());
default
:
break
;
}
}
/*
* Redirect if token mismatch error
* Usually because user stayed on the same screen too long and their session expired
*/
if
(
$exception
instanceof
TokenMismatchException
)
{
return
redirect
()
->
route
(
'frontend.auth.login'
);
}
...
...
@@ -75,6 +104,7 @@ class Handler extends ExceptionHandler
*/
protected
function
unauthenticated
(
$request
,
AuthenticationException
$exception
)
{
if
(
$request
->
expectsJson
())
{
return
response
()
->
json
([
'error'
=>
'Unauthenticated.'
],
401
);
}
...
...
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