|
|
@@ -1,12 +1,12 @@
|
|
|
<script>
|
|
|
import {onMount} from 'svelte';
|
|
|
- import {auth} from '../store.js';
|
|
|
+ import {authentication} from '../store.js';
|
|
|
|
|
|
let isAuthenticated = false;
|
|
|
let isLoading = true;
|
|
|
let user = null;
|
|
|
|
|
|
- $: auth.subscribe(value => {
|
|
|
+ $: authentication.subscribe(value => {
|
|
|
isAuthenticated = !!value;
|
|
|
if (value) {
|
|
|
user = value;
|
|
|
@@ -15,9 +15,9 @@
|
|
|
|
|
|
onMount(() => {
|
|
|
try {
|
|
|
- const storedAuth = localStorage.getItem('auth');
|
|
|
+ const storedAuth = localStorage.getItem('authentication');
|
|
|
if (storedAuth) {
|
|
|
- auth.set(JSON.parse(storedAuth));
|
|
|
+ authentication.set(JSON.parse(storedAuth));
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('Error parsing stored auth:', error);
|
|
|
@@ -54,8 +54,8 @@
|
|
|
|
|
|
if (response.ok) {
|
|
|
const result = await response.json();
|
|
|
- auth.set(result);
|
|
|
- localStorage.setItem('auth', JSON.stringify(result));
|
|
|
+ authentication.set(result);
|
|
|
+ localStorage.setItem('authentication', JSON.stringify(result));
|
|
|
} else {
|
|
|
const error = await response.json();
|
|
|
console.error('Login failed:', error);
|