svelte-migrate: renamed files

This commit is contained in:
nemunaire 2022-12-12 08:49:28 +01:00
commit 4d6149760d
30 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,81 @@
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores'
import AuthButton from '$lib/components/AuthButton.svelte';
import { ToastsStore } from '$lib/stores/toasts';
import { user } from '$lib/stores/user';
let auth = { username: "", password: "" };
let pleaseWait = false;
export let next = $page.url.searchParams.get('next');
function logmein() {
pleaseWait = true;
fetch('api/auth', {
method: 'POST',
body: JSON.stringify(auth),
})
.then((response) => {
if (response.status == 200) {
response.json().then((auth) => {
pleaseWait = false;
if (next && next.indexOf('//') === -1) {
goto(next)
} else {
goto(".");
}
})
} else {
pleaseWait = false;
response.json().then((data) => {
ToastsStore.addToast({
color: "danger",
title: "Connexion impossible",
msg: (data ? data.errmsg : "Impossible de contacter le serveur"),
});
});
}
});
}
$: {
if ($user && $user.id) {
if (next && next.indexOf('//') === -1) {
goto(next)
} else {
goto(".");
}
}
}
</script>
<div class="row">
<form class="col" on:submit|preventDefault={logmein}>
<h2>Accès à votre compte</h2>
<div class="form-floating mb-3">
<input type="text" class="form-control" id="login" bind:value={auth.username} placeholder="xavier.login" autofocus>
<label for="login">CRI login</label>
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control" id="password" bind:value={auth.password} placeholder="Mot de passe">
<label for="password">Mot de passe</label>
</div>
<button type="submit" class="btn btn-info">
{#if pleaseWait}
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
{/if}
Me connecter
</button>
</form>
<div class="col">
<h2>OpenId Connect</h2>
<div class="text-center">
<AuthButton class="btn btn-primary">
Me connecter avec mon compte CRI
</AuthButton>
</div>
</div>
</div>