Convert backend/web from submodule to regular directory
This commit is contained in:
1 parent
102a316d42
commit
0010c92103
89 files changed
+6559
-1
No files matched your search
@@ -0,0 +1,105 @@
|
||||
<script lang="ts">
|
||||
import logo from "$lib/assets/logo-txt.png"
|
||||
import { auth, setToken } from '$lib/state/auth.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { authApi } from "$lib/api/endpoints/auth"
|
||||
|
||||
type Credentials = {
|
||||
email: string
|
||||
validemail: boolean
|
||||
password : string
|
||||
}
|
||||
|
||||
let credentials: Credentials = $state({
|
||||
email: "",
|
||||
password: "",
|
||||
validemail: false
|
||||
})
|
||||
|
||||
const formSubmitEmail = () => {
|
||||
credentials.validemail = true
|
||||
}
|
||||
|
||||
const formSubmitPass = (e: Event) => {
|
||||
e.preventDefault()
|
||||
authApi.login(credentials)
|
||||
.then((res)=>{
|
||||
auth.user = res.user
|
||||
setToken(res.accessToken)
|
||||
goto("/")
|
||||
})
|
||||
.catch((err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="h-full w-full flex items-center public">
|
||||
<div class="m-auto w-96 max-w-full p-4">
|
||||
<img src={logo} class="h-10 mb-4" alt="logo"/>
|
||||
<h1>Identifiez-vous ...</h1>
|
||||
{#if !credentials.validemail}
|
||||
<form onsubmit={formSubmitEmail}>
|
||||
<div class="flex">
|
||||
<label for="email" class="block mb-2 flex-1">Email</label>
|
||||
<a href="/recover-password" class="text-xs">Mot de passe oublié ?</a>
|
||||
</div>
|
||||
<div class="flex flex-row">
|
||||
<input
|
||||
type="text"
|
||||
bind:value={credentials.email}
|
||||
class="textinput mr-1"
|
||||
autofocus
|
||||
/>
|
||||
<button class="bt" title="page suivante">
|
||||
<i class="icon-right-big"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="my-4 text-xs">
|
||||
<a href="/register">Pas encore de compte ? Incrivez-vous.</a>
|
||||
</div>
|
||||
|
||||
|
||||
{:else}
|
||||
<form onsubmit={formSubmitPass}>
|
||||
<div class="flex">
|
||||
<label for="email" class="block mb-2 flex-1">Mot de passe</label>
|
||||
</div>
|
||||
<div class="flex flex-row">
|
||||
<input
|
||||
type="password"
|
||||
bind:value={credentials.password}
|
||||
class="textinput mr-1"
|
||||
autofocus
|
||||
/>
|
||||
<button class="bt">
|
||||
Entrer
|
||||
</button>
|
||||
</div>
|
||||
<a href="/login" class="text-xs" onclick={()=>{credentials.validemail=false}}>← Retour</a>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
|
||||
<hr class="my-4">
|
||||
|
||||
<div class="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-4">
|
||||
<button class="bt p-5 text-center" title="Connexion avec Google">
|
||||
<i class="icon-google"></i>
|
||||
</button>
|
||||
<button class="bt p-5 text-center" title="Connexion avec Facebook">
|
||||
<i class="icon-facebook"></i>
|
||||
</button>
|
||||
<button class="bt p-5 text-center" title="Connexion avec Github">
|
||||
<i class="icon-github"></i>
|
||||
</button>
|
||||
<button class="bt p-5 text-center" title="Connexion avec Apple">
|
||||
<i class="icon-apple"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,120 @@
|
||||
<script lang="ts">
|
||||
import logo from "$lib/assets/logo-txt.png"
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import { goto } from '$app/navigation';
|
||||
import { validateEmail } from '$lib/utilities/validators'
|
||||
import FormError from "$lib/components/FormError.svelte";
|
||||
import { authApi } from "$lib/api/endpoints/auth"
|
||||
|
||||
type RegisterForm = {
|
||||
email: string
|
||||
firstname: string
|
||||
lastname: string
|
||||
password : string
|
||||
verifPassword: string
|
||||
}
|
||||
|
||||
let errors = new SvelteMap<string,string>()
|
||||
|
||||
let form: RegisterForm = $state({
|
||||
email: "",
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
password: "",
|
||||
verifPassword: ""
|
||||
})
|
||||
|
||||
const handleSubmit = (e: Event) => {
|
||||
e.preventDefault()
|
||||
errors.clear()
|
||||
|
||||
if (!validateEmail(form.email)) {
|
||||
errors.set("email","Adresse email invalide !")
|
||||
}
|
||||
if (form.password!==form.verifPassword) {
|
||||
errors.set("verifPassword","Les mots de pass ne correspondent pas.")
|
||||
}
|
||||
if (errors.size==0) {
|
||||
|
||||
let data = {
|
||||
method: "password",
|
||||
email: form.email,
|
||||
firstname: form.firstname,
|
||||
lastname: form.lastname,
|
||||
password: form.password
|
||||
}
|
||||
|
||||
authApi.register(data)
|
||||
.then(()=>{ goto("/") })
|
||||
.catch((reason: string)=>{ errors.set("submit","Erreur: "+reason) })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="h-full w-full flex items-center public">
|
||||
<div class="m-auto w-96 max-w-full p-4">
|
||||
<img src={logo} class="h-10 mb-4" alt="logo"/>
|
||||
<h1>Inscription</h1>
|
||||
|
||||
<form onsubmit={handleSubmit} onchange={()=>{errors.clear()}}>
|
||||
|
||||
<label for="email" class="block my-1 flex-1">Email</label>
|
||||
<input
|
||||
id="email"
|
||||
type="text"
|
||||
bind:value={form.email}
|
||||
class="textinput"
|
||||
autofocus
|
||||
/>
|
||||
<FormError key="email" errors={errors} />
|
||||
|
||||
|
||||
<label for="firstname" class="block my-1 flex-1">Prénom</label>
|
||||
<input
|
||||
id="firstname"
|
||||
type="text"
|
||||
bind:value={form.firstname}
|
||||
class="textinput"
|
||||
/>
|
||||
<FormError key="firstname" {errors} />
|
||||
|
||||
<label for="lastname" class="block my-1 flex-1">Nom</label>
|
||||
<input
|
||||
id="lastname"
|
||||
type="text"
|
||||
bind:value={form.lastname}
|
||||
class="textinput"
|
||||
/>
|
||||
<FormError key="lastname" {errors} />
|
||||
|
||||
<label for="password" class="block my-1 flex-1">Mot de passe</label>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
bind:value={form.password}
|
||||
class="textinput"
|
||||
/>
|
||||
<FormError key="password" {errors} />
|
||||
|
||||
<label for="verifpassword" class="block my-1 flex-1">Vérification du mot de passe</label>
|
||||
<input
|
||||
id="verifpassword"
|
||||
type="password"
|
||||
bind:value={form.verifPassword}
|
||||
class="textinput"
|
||||
/>
|
||||
<FormError key="verifPassword" {errors} />
|
||||
|
||||
<button class="bt my-2 w-full ">
|
||||
Enregistrer
|
||||
</button>
|
||||
|
||||
<FormError key="submit" {errors} />
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user