enhanced login?
Some checks failed
Build and Deploy / build (push) Failing after 6s

This commit is contained in:
Mohamad 2024-12-30 14:54:16 +01:00
parent 50d03a5387
commit 542d8583ab

View File

@ -1,6 +1,8 @@
<script lang="ts">
import { adminLogin } from '$lib/api';
import { createEventDispatcher } from 'svelte';
import { createEventDispatcher, onMount } from 'svelte';
import session from '$lib/session.svelte';
let username = '';
let password = '';
let errorMessage = '';
@ -14,7 +16,14 @@
try {
const token = await adminLogin({ username, password });
dispatch('login', { token }); // Dispatch the token to the parent component or handle it here
// Store session data
session.login({
username,
password_hash: token // Assuming the token acts as a password hash for session purposes
});
dispatch('login', { username, token });
alert('Login successful!');
} catch (error: any) {
errorMessage = error.message || 'Login failed. Please try again.';
@ -52,10 +61,6 @@
{#if errorMessage}
<div class="error-message">{errorMessage}</div>
{/if}
{#if loading}
<div class="loading">Loading...</div>
{/if}
</form>
<style>
@ -95,11 +100,4 @@
font-size: 14px;
margin-top: 10px;
}
.loading {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
</style>