Token auth filter now return 440 http code on expired token
This commit is contained in:
parent
c2e0951144
commit
9165770546
@ -97,6 +97,11 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
} else {
|
||||
userTokenService.deleteToken(userToken.getUserName());
|
||||
TokenCacheUtil.evictSingleTokenValue(userToken.getTokenContent());
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE);
|
||||
response.setStatus(440);
|
||||
response.getWriter().write("Token authentication error: Token has expired");
|
||||
logger.warn("Token authentication error: Token has expired");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -330,6 +330,7 @@ async function getAllMessages(toUser) {
|
||||
method: 'GET',
|
||||
headers: headers
|
||||
});
|
||||
console.log(response);
|
||||
let data = await response.json();
|
||||
return data;
|
||||
}
|
||||
@ -342,6 +343,12 @@ async function getNewMessages(toUser, lastMessageTimeStamp) {
|
||||
method: 'GET',
|
||||
headers: headers
|
||||
});
|
||||
console.log(response);
|
||||
if(response.status == 440)
|
||||
{
|
||||
window.alert('Token has expired. Please login again');
|
||||
return;
|
||||
}
|
||||
let data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user