added user repo and group management working now

This commit is contained in:
2019-04-11 16:18:18 +02:00
parent 654c78ff7c
commit 98f5d3f39b
11 changed files with 236 additions and 97 deletions

View File

@@ -7,6 +7,33 @@ import store from "@/store";
const baseDomain = "http://localhost:5443";
const API_URL = `${baseDomain}/api/v1`;
export default axios.create({
const api = axios.create({
baseURL: API_URL, headers: { Authorization: `Bearer ${store.state.access_token}` },
});
api.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
Vue.swal({
title: "Session Expired",
text: "Your token/session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
}).then( (result) => {
if(result.value) {
console.log("redirect to login!");
window.location = '/login';
} else {
console.log("redirect to home!");
window.location = '/';
}
});
} else {
return Promise.reject(error);
}
});
export default api;