[WIP] Переход на страницу лоина, если токен просрочился

This commit is contained in:
megavrilinvv
2022-12-07 11:47:48 +03:00
parent fe317a0619
commit 8cb7da166e
2 changed files with 17 additions and 9 deletions

View File

@@ -105,9 +105,12 @@ export default {
this.employeesData = res.results; this.employeesData = res.results;
}, },
fetchEmployeesData() { fetchEmployeesData() {
fetchWrapper fetchWrapper.get("general/employee/").then((res) => {
.get("general/employee/") if (res.type === "client_error") {
.then((res) => this.saveEmployeesData(res)); localStorage.clear();
this.$router.push("/login");
} else this.saveEmployeesData(res);
});
}, },
fetchEventsData() { fetchEventsData() {
fetchWrapper fetchWrapper

View File

@@ -138,6 +138,10 @@ export default {
(this.currentTablePage - 1) * this.limit (this.currentTablePage - 1) * this.limit
}` }`
); );
if (response.type === "client_error") {
localStorage.clear();
this.$router.push("/login");
} else {
this.saveDataClients(response); this.saveDataClients(response);
this.saveClientsCount(response); this.saveClientsCount(response);
this.paginationInfo = { this.paginationInfo = {
@@ -145,6 +149,7 @@ export default {
length: this.calculatePageCount(this.clientsCount), length: this.calculatePageCount(this.clientsCount),
}; };
} }
}
}, },
calculatePageCount(count) { calculatePageCount(count) {
return Math.ceil(count / this.limit); return Math.ceil(count / this.limit);