redirect when refreshData fails?
lucianobosco opened this issue · comments
I'm debugging my refresh token functionality with v4 of vue-auth
.
The refreshData is triggered every 1 minute. If the token is still valid I just return a dummy message with status code 200:
return response()->json(['message'=> 'Token is still valid'], 200);
If something goes wrong I'm returning a 401
return response()->json(['message'=> 'Something went wrong'], 401);
What does this function expect as a fail response?
I see nothing happens when refresh receives a non 200 status code. Shouldn't it redirect to login page?
This is my refreshData config:
refreshData: {
url: '/refresh',
method: 'POST',
enabled: true,
interval: 1
},
EDIT:
I figure out that by adding this to driver auth on response works as expected:
response: function (res) {
if (res.status === 401) this.logout()
}
I this enough or should I consider anything else? I thought about adding in Axios response interceptor but because of modularized apps maybe some components are restricted in the same page and I don't want to redirect if an Axios response returns 401.
Any advice will be appreciated