Skip to content

Commit 9393b75

Browse files
cristiano-pachecovinicius73
authored andcommitted
Fix redirect when the token is invalid. (#24)
thanks
1 parent 8938513 commit 9393b75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

client/src/plugins/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ http.interceptors.response.use(
2828
* then redirect to login. On server side the error
2929
* messages can be changed on app/Providers/EventServiceProvider.php
3030
*/
31-
if (error.response.data.reason === 'token') {
31+
if (error.response.status === 401) {
3232
router.push({ name: 'login.index' })
3333
}
3434
/**

webservice/app/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function handleExceptionJsonResponse(Exception $exception)
7676
protected function unauthenticated($request, AuthenticationException $exception)
7777
{
7878
if ($request->expectsJson()) {
79-
return response()->json(['error' => 'Unauthenticated.'], 401);
79+
return response()->json(['error' => ['Unauthenticated.']], 401);
8080
}
8181

8282
return redirect()->guest('login');

0 commit comments

Comments
 (0)