feat: astro template for front and fix login(#13)
Reviewed-on: #13 Co-authored-by: Clement <c.boesmier@aptatio.com> Co-committed-by: Clement <c.boesmier@aptatio.com>
This commit is contained in:
53
front/src/components/Oauth.astro
Normal file
53
front/src/components/Oauth.astro
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
import ContactUs from 'components/widgets/Contact.astro';
|
||||
import CallToAction from 'components/widgets/CallToAction.astro';
|
||||
|
||||
const pb = Astro.locals.pb
|
||||
const oauths = (await pb.collection('users').listAuthMethods()).authProviders;
|
||||
const discordProvider = oauths.find(item => item.name === 'discord');
|
||||
const googleProvider = oauths.find(item => item.name === 'google');
|
||||
|
||||
---
|
||||
|
||||
<>
|
||||
<CallToAction
|
||||
actions={[
|
||||
{
|
||||
variant: 'primary',
|
||||
text: 'Discord',
|
||||
href: discordProvider!.authUrl + Astro.url.protocol + "//" + Astro.url.host + '/account/oauth',
|
||||
icon: 'tabler:brand-discord',
|
||||
class: "oauth-btn",
|
||||
"data-cookie": encodeURIComponent(JSON.stringify(discordProvider))
|
||||
},
|
||||
{
|
||||
variant: 'primary',
|
||||
text: 'Google',
|
||||
href: googleProvider!.authUrl + Astro.url.protocol + "//" + Astro.url.host + '/account/oauth',
|
||||
icon: 'tabler:brand-google',
|
||||
class: "oauth-btn",
|
||||
"data-cookie": encodeURIComponent(JSON.stringify(googleProvider))
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Fragment slot="title">
|
||||
Oauth
|
||||
</Fragment>
|
||||
|
||||
<Fragment slot="subtitle">
|
||||
Connecter Vous aussi avec
|
||||
</Fragment>
|
||||
</CallToAction>
|
||||
</>
|
||||
|
||||
<script>
|
||||
// import { date } from "astro/zod";
|
||||
|
||||
document.cookie = "provider" + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
// console.log(date.toString)
|
||||
|
||||
const btn = document.querySelectorAll('.oauth-btn')
|
||||
btn.forEach((item: Element) =>(item.addEventListener('click', (ev) =>{
|
||||
document.cookie = "provider" + "=" + item.getAttribute('data-cookie') + "; path=/;"// expires=" + ;
|
||||
})))
|
||||
</script>
|
Reference in New Issue
Block a user