feat: gestion-utilisateur #1
@ -15,24 +15,34 @@ await AstroUtils.wrap(async () => {
|
||||
return
|
||||
}
|
||||
const form = await Astro.request.formData()
|
||||
const request = {
|
||||
username: form.get("username") as string,
|
||||
name: form.get("name") as string,
|
||||
email: form.get("email") as string,
|
||||
password: form.get("password") as string,
|
||||
passwordConfirm: form.get("passwordConfirm") as string,
|
||||
}
|
||||
try{
|
||||
await pb.collection('users').create(request)
|
||||
return Astro.redirect('/account/login')
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
if(form.get("type") == "userPassword"){
|
||||
const request = {
|
||||
username: form.get("username") as string,
|
||||
name: form.get("name") as string,
|
||||
email: form.get("email") as string,
|
||||
password: form.get("password") as string,
|
||||
passwordConfirm: form.get("passwordConfirm") as string,
|
||||
}
|
||||
try{
|
||||
await pb.collection('users').create(request)
|
||||
return Astro.redirect('/account/login')
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
}else if (form.get("type") == "discord2FA") {
|
||||
// console.log("pouet")
|
||||
// await pb.collection('user').authWithOAuth2({provider: 'discord'})
|
||||
// console.log("pouetF");
|
||||
|
||||
}else{
|
||||
Astro.redirect("/404")
|
||||
}
|
||||
})
|
||||
---
|
||||
|
||||
<Layout title="register">
|
||||
<form id="account-creation" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="type" value="userPassword">
|
||||
<input required name="name" placeholder="Prénom Nom"/>
|
||||
<input required name="username" placeholder="Pseudo"/>
|
||||
<input required name="email" type="email" placeholder="Renseignez votre email" />
|
||||
@ -40,4 +50,21 @@ await AstroUtils.wrap(async () => {
|
||||
<input required name="passwordConfirm" type="password" placeholder="Confirmer votre mot de passe" />
|
||||
<button>Créer un compte</button>
|
||||
</form>
|
||||
</Layout>
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="type" value="discord2FA">
|
||||
<button id="OauthDiscord">connexion avec discord</button>
|
||||
</form>
|
||||
</Layout>
|
||||
|
||||
<script>
|
||||
import PocketBase from 'pocketbase'
|
||||
const pb = Astro.locals.pb
|
||||
const discordBtn = document.querySelector<HTMLButtonElement>("#OauthDiscord")
|
||||
|
||||
if (discordBtn) {
|
||||
discordBtn.addEventListener('onclick', async () =>{
|
||||
await pb.collection('user').authWithOAuth2({provider: 'discord'})
|
||||
})
|
||||
}
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user