add function tokenLifeExtension

This commit is contained in:
smanylov
2026-01-12 13:39:35 +07:00
parent 6b9279f802
commit cb5a005041
4 changed files with 39 additions and 6 deletions
+34 -3
View File
@@ -18,10 +18,10 @@ export async function logout() {
});
} catch (error) {
throw error;
} finally {
await deleteSession();
redirect('/login');
}
await deleteSession();
redirect('/login');
}
export async function authorization(
@@ -276,4 +276,35 @@ export async function registration(
}
redirect('/pages/dashboard');
}
export async function tokenLifeExtension() {
const token = await getSessionData('token');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
version: 1,
msg_id: 20008,
message_body: {
token: token
}
}),
});
if (response.ok) {
const parsed = await response.json();
console.log('tokenLifeExtension');
console.log(parsed.message_code);
}
} catch (error) {
await deleteSession();
redirect('/login');
throw error;
}
}