sync register change
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
---
|
||||
import Layout from 'layouts/Layout.astro';
|
||||
import AstroUtils from 'libs/AstroUtils';
|
||||
import PocketBase from 'pocketbase'
|
||||
|
||||
|
||||
const pb = Astro.locals.pb
|
||||
|
||||
const oauths = await pb.collection('users').listAuthMethods();
|
||||
|
||||
if(pb.authStore.isValid){
|
||||
return Astro.redirect("/account")
|
||||
}
|
||||
@ -51,20 +51,25 @@ await AstroUtils.wrap(async () => {
|
||||
<button>Créer un compte</button>
|
||||
</form>
|
||||
|
||||
<button id="OauthDiscord">connexion avec discord</button>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="type" value="discord2FA">
|
||||
<button id="OauthDiscord">connexion avec discord</button>
|
||||
</form>
|
||||
<a href={oauths.authProviders[1].authUrl + "https%3A%2F%2Fpb-tweb.cb85.fr%2Fapi%2Foauth2-redirect"}>discord?</a>
|
||||
</Layout>
|
||||
|
||||
<script>
|
||||
import PocketBase from 'pocketbase'
|
||||
const pb = Astro.locals.pb
|
||||
import 'cross-fetch/polyfill';
|
||||
import PocketBase from "pocketbase"
|
||||
import type { OAuth2UrlCallback } from "pocketbase"
|
||||
const pb = new PocketBase("https://pb-tweb.cb85.fr/")
|
||||
const discordBtn = document.querySelector<HTMLButtonElement>("#OauthDiscord")
|
||||
|
||||
if (discordBtn) {
|
||||
discordBtn.addEventListener('onclick', async () =>{
|
||||
await pb.collection('user').authWithOAuth2({provider: 'discord'})
|
||||
discordBtn.addEventListener('click', async () =>{
|
||||
const result = await pb.collection('users').listAuthMethods();
|
||||
fetch(result.authProviders[0].authUrl)
|
||||
console.log(result);
|
||||
})
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user