feat: gestion-utilisateur #1

Merged
Clement merged 37 commits from feat/gestion-utilisateur into master 2024-05-20 10:48:35 +00:00
3 changed files with 60 additions and 7 deletions
Showing only changes of commit 56345d9933 - Show all commits

View File

@ -15,6 +15,7 @@
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"astro": "4.5.12",
"cross-fetch": "^4.0.0",
"leaflet": "^1.9.4",
"lucide-astro": "^0.372.0",
"pocketbase": "^0.21.1",
@ -3340,6 +3341,14 @@
"node": ">= 0.6"
}
},
"node_modules/cross-fetch": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
"integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==",
"dependencies": {
"node-fetch": "^2.6.12"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -7178,6 +7187,25 @@
"integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==",
"optional": true
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-releases": {
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
@ -9869,6 +9897,11 @@
"node": ">=0.6"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",
@ -11088,6 +11121,20 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View File

@ -19,6 +19,7 @@
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"astro": "4.5.12",
"cross-fetch": "^4.0.0",
"leaflet": "^1.9.4",
"lucide-astro": "^0.372.0",
"pocketbase": "^0.21.1",

View File

@ -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>