<script setup>
const accessrefresh = async () => {
axios.defaults.headers.common['Authorization'] = storeaccesstoken.accesstoken;
await axios.create({withCredentials: true}).post("http://localhost:81/auth/refresh/")
.then((response) => { axios.defaults.headers.common['Authorization'] = response.data.token;
storeaccesstoken.stateAccessToken(response.data.token);
})
.catch((errors) => {
console.log("errors access refresh: ",errors);
if(errors?.response?.data?.message==='error') {
Swal.fire({
title: "Error!",
text: "Access denied!",
icon: "error",
confirmButtonText: "Log in please!"
});
}
storeaccesstoken.stateAccessToken(null);
storeaccesstoken.setStateUserFalse();
router.push({ path: '/login' })
});
};
onBeforeMount(() => {
window.addEventListener("beforeunload",accessrefresh());
})
<script>
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)