refactor: improve code formatting and consistency in auth and login components

This commit is contained in:
ArielLeyva 2025-09-18 15:00:11 -04:00
parent 03664c61ba
commit 4feba703f7
3 changed files with 12 additions and 11 deletions

View File

@ -24,7 +24,7 @@ export function parseToken(token: string) {
const expiresAt = new Date(data.exp! * 1000); const expiresAt = new Date(data.exp! * 1000);
authStore.setLogoutTimer( authStore.setLogoutTimer(
window.setTimeout(() => { window.setTimeout(() => {
logout('inactivity'); logout("inactivity");
}, expiresAt.getTime() - Date.now()) }, expiresAt.getTime() - Date.now())
); );
} }
@ -113,16 +113,15 @@ export function logout(reason?: string) {
if (noAuth) { if (noAuth) {
window.location.reload(); window.location.reload();
} else { } else {
if(typeof reason === "string" && reason.trim() !== "") { if (typeof reason === "string" && reason.trim() !== "") {
router.push({ router.push({
path: "/login", path: "/login",
query: { "logout-reason": reason } query: { "logout-reason": reason },
}); });
} else { } else {
router.push({ router.push({
path: "/login", path: "/login",
}); });
} }
} }
} }

View File

@ -3,7 +3,9 @@
<form @submit="submit"> <form @submit="submit">
<img :src="logoURL" alt="File Browser" /> <img :src="logoURL" alt="File Browser" />
<h1>{{ name }}</h1> <h1>{{ name }}</h1>
<p v-if="reason != null" class="logout-message">{{t(`login.logout_reasons.${reason}`)}}</p> <p v-if="reason != null" class="logout-message">
{{ t(`login.logout_reasons.${reason}`) }}
</p>
<div v-if="error !== ''" class="wrong">{{ error }}</div> <div v-if="error !== ''" class="wrong">{{ error }}</div>
<input <input
@ -71,7 +73,7 @@ const toggleMode = () => (createMode.value = !createMode.value);
const $showError = inject<IToastError>("$showError")!; const $showError = inject<IToastError>("$showError")!;
const reason = route.query['logout-reason'] ?? null; const reason = route.query["logout-reason"] ?? null;
const submit = async (event: Event) => { const submit = async (event: Event) => {
event.preventDefault(); event.preventDefault();