diff --git a/src/lib/auth/Auth.js b/src/lib/auth/Auth.js
index 11cf0bd..c761a67 100644
--- a/src/lib/auth/Auth.js
+++ b/src/lib/auth/Auth.js
@@ -26,11 +26,15 @@ export async function checkAuth() {
export function checkAuthSync() {
let result = getAuthInfo();
+ // console.log('+');
if (!result) return false;
+ // console.log('-');
try {
let decoded = jwtDecode(result.a);
+ // console.log('жопа');
return !isPast(parseISO(new Date(decoded.exp * 1000).toISOString()));
} catch (e) {
+ // console.log('хуй');
return false;
}
}
diff --git a/src/lib/ui-components/navbar.svelte b/src/lib/ui-components/navbar.svelte
index 8bf030d..c1f161d 100644
--- a/src/lib/ui-components/navbar.svelte
+++ b/src/lib/ui-components/navbar.svelte
@@ -1,6 +1,7 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte
index 63f5662..f7e286e 100644
--- a/src/routes/login/+page.svelte
+++ b/src/routes/login/+page.svelte
@@ -2,8 +2,9 @@
import { makePost } from "$lib/tools/requests/Requests";
import { sayError, sayInfo, sayWarning } from "$lib/tools/toaster/Toaster";
import { onMount } from "svelte";
- import {checkAuth, saveAuthInfo} from "../../lib/auth/Auth";
+ import { checkAuth, saveAuthInfo } from "../../lib/auth/Auth";
import { redirect } from "$lib/tools/url/URLTools";
+ import { AuthStorage } from "$lib/tools/storages/auth-storage";
//6da8a96a-7253-45e2-a3c1-e00d5ecdc65d - valid
let tokenValid = true;
@@ -23,20 +24,20 @@
totpValid = true;
showLoadingSpinner = true;
const result = await makePost("client/login", {
- "user_token": input_token.value,
- "totp": input_totp.value
+ user_token: input_token.value,
+ totp: input_totp.value,
});
- if(result.error)
- {
+ if (result.error) {
sayError("Ошибка входа!");
tokenValid = false;
totpValid = false;
showLoadingSpinner = false;
return;
- }
- else
- {
+ } else {
saveAuthInfo(result.data.token);
+ AuthStorage.update((s) => {
+ s.logged = true;
+ });
redirect("/admin/");
showLoadingSpinner = false;
return;
@@ -87,15 +88,31 @@
on:click={() => {
sendLogin();
}}
- class="btn btn-primary text-lg">
+ class="btn btn-primary text-lg"
+ >
Войти
{#if showLoadingSpinner}
-
+
{/if}
-
+