bug fix in user check login and jump to login page

This commit is contained in:
Hesabix 2025-08-14 10:04:43 +00:00
parent 56964c96b7
commit b1ce11930e

View file

@ -48,7 +48,25 @@ export default {
}
}
},
mounted() {
async mounted() {
// بررسی وضعیت لاگین کاربر
try {
const loginCheck = await axios.post('/api/user/check/login');
if (loginCheck.data.Success !== true) {
// اگر کاربر لاگین نباشد، توکن را حذف کرده و به صفحه ورود هدایت میکنیم
localStorage.removeItem('X-AUTH-TOKEN');
delete axios.defaults.headers.common['X-AUTH-TOKEN'];
this.$router.push('/user/login');
return;
}
} catch (error) {
// در صورت خطا در بررسی لاگین، توکن را حذف کرده و به صفحه ورود هدایت میکنیم
localStorage.removeItem('X-AUTH-TOKEN');
delete axios.defaults.headers.common['X-AUTH-TOKEN'];
this.$router.push('/user/login');
return;
}
axios.post('/api/plugin/get/actives').then((response) => {
this.plugins = response.data;
});