feat: gestion-utilisateur #1
@ -15,24 +15,34 @@ await AstroUtils.wrap(async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const form = await Astro.request.formData()
|
const form = await Astro.request.formData()
|
||||||
const request = {
|
if(form.get("type") == "userPassword"){
|
||||||
username: form.get("username") as string,
|
const request = {
|
||||||
name: form.get("name") as string,
|
username: form.get("username") as string,
|
||||||
email: form.get("email") as string,
|
name: form.get("name") as string,
|
||||||
password: form.get("password") as string,
|
email: form.get("email") as string,
|
||||||
passwordConfirm: form.get("passwordConfirm") as string,
|
password: form.get("password") as string,
|
||||||
}
|
passwordConfirm: form.get("passwordConfirm") as string,
|
||||||
try{
|
}
|
||||||
await pb.collection('users').create(request)
|
try{
|
||||||
return Astro.redirect('/account/login')
|
await pb.collection('users').create(request)
|
||||||
}catch(e){
|
return Astro.redirect('/account/login')
|
||||||
console.log(e);
|
}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">
|
<Layout title="register">
|
||||||
<form id="account-creation" method="post" enctype="multipart/form-data">
|
<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="name" placeholder="Prénom Nom"/>
|
||||||
<input required name="username" placeholder="Pseudo"/>
|
<input required name="username" placeholder="Pseudo"/>
|
||||||
<input required name="email" type="email" placeholder="Renseignez votre email" />
|
<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" />
|
<input required name="passwordConfirm" type="password" placeholder="Confirmer votre mot de passe" />
|
||||||
<button>Créer un compte</button>
|
<button>Créer un compte</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="type" value="discord2FA">
|
||||||
|
<button id="OauthDiscord">connexion avec discord</button>
|
||||||
|
</form>
|
||||||
</Layout>
|
</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