From 227c41a90d6146f4d0dd42f89df7f03efda895fa Mon Sep 17 00:00:00 2001 From: Derick Montague Date: Fri, 20 Dec 2019 17:08:59 -0600 Subject: Redirect user to login on 401 response Signed-off-by: Derick Montague Change-Id: I58609486956239d90a0dfec630f249dc3fa28ea2 --- src/store/api.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/store/api.js b/src/store/api.js index 463e0d86..04caea12 100644 --- a/src/store/api.js +++ b/src/store/api.js @@ -4,6 +4,14 @@ const api = Axios.create({ withCredentials: true }); +api.interceptors.response.use(undefined, error => { + let response = error.response; + // TODO: Provide user with a notification and way to keep system active + if (response.status == 401) { + window.location = '/login'; + } +}); + export default { get(path) { return api.get(path); -- cgit v1.2.3