wirking on global error display

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-26 14:45:19 +02:00
parent 9c4c71f7dd
commit 2a6392cd2b
14 changed files with 113 additions and 116 deletions

View File

@@ -2,22 +2,21 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../urls.svelte.js';
import { checkUser, tryLogin } from '../user.svelte.js';
import { t } from '../translations.svelte.js';
import { api } from '../urls.svelte';
import { error, yikes } from '../warn.svelte';
import { checkUser, tryLogin } from '../user.svelte';
import { t } from '../translations.svelte';
let credentials = $state({ username : null, password : null });
const router = useTinyRouter();
let services = $state([]);
let error = $state(null);
async function doLogin(ev){
ev.preventDefault();
const json = await tryLogin(credentials);
if (json) {
json.release_time = json.release_time.replace('T',' ');
error = t('failed_login_attempts',json);
error(t('failed_login_attempts',json));
}
}
@@ -43,13 +42,14 @@
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
const json = await resp.json();
yikes();
if (json.authorization_endpoint) {
const endpoint = json.authorization_endpoint;
delete json.authorization_endpoint;
location.href = endpoint + '?' + new URLSearchParams(json);
}
} else {
error = await resp.text();
error(await resp.text());
if (btn) btn.disabled = false;
}
}
@@ -85,9 +85,6 @@
<form onsubmit={doLogin}>
<fieldset>
{#if error}
<span class="error">{error}</span>
{/if}
<legend>{t('login')}</legend>
<label>
<input type="text" bind:value={credentials.username} required use:init />

View File

@@ -5,7 +5,6 @@
import Autocomplete from './Autocomplete.svelte';
let error = $state(null);
let {
getCandidates = async text => {},
heading = t('add_object',{object:t('user')}),
@@ -25,9 +24,6 @@
let sortedUsers = $derived.by(() => Object.values(users).sort((a, b) => a.name.localeCompare(b.name)));
</script>
{#if error}
<span class="error">{error}</span>
{/if}
<table>
<tbody>
{#each sortedUsers as usr,idx}