Compare commits
9 Commits
v0.0.1
...
eed351df0a
Author | SHA1 | Date | |
---|---|---|---|
eed351df0a | |||
5a49f5beda | |||
70382d7bd8 | |||
a724c1270f | |||
7c68628456 | |||
a2290c21e1 | |||
79656cfccd | |||
65d52eb8fa | |||
65ddbe976f |
@ -3,6 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
|
"private": "true",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"start": "node ./dist/server/entry.mjs",
|
"start": "node ./dist/server/entry.mjs",
|
||||||
|
@ -19,33 +19,4 @@ const { title } = Astro.props;
|
|||||||
<body>
|
<body>
|
||||||
<slot />
|
<slot />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<style is:global>
|
|
||||||
:root {
|
|
||||||
--accent: 136, 58, 234;
|
|
||||||
--accent-light: 224, 204, 250;
|
|
||||||
--accent-dark: 49, 10, 101;
|
|
||||||
--accent-gradient: linear-gradient(
|
|
||||||
45deg,
|
|
||||||
rgb(var(--accent)),
|
|
||||||
rgb(var(--accent-light)) 30%,
|
|
||||||
white 60%
|
|
||||||
);
|
|
||||||
}
|
|
||||||
html {
|
|
||||||
font-family: system-ui, sans-serif;
|
|
||||||
background: #13151a;
|
|
||||||
background-size: 224px;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
font-family:
|
|
||||||
Menlo,
|
|
||||||
Monaco,
|
|
||||||
Lucida Console,
|
|
||||||
Liberation Mono,
|
|
||||||
DejaVu Sans Mono,
|
|
||||||
Bitstream Vera Sans Mono,
|
|
||||||
Courier New,
|
|
||||||
monospace;
|
|
||||||
}
|
|
||||||
</style>
|
|
5
front/src/libs/AstroUtils.ts
Normal file
5
front/src/libs/AstroUtils.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export default class AstroUtils {
|
||||||
|
public static async wrap<T = void>(fn: () => T | Promise<T>) {
|
||||||
|
return await fn()
|
||||||
|
}
|
||||||
|
}
|
44
front/src/pages/account/login.astro
Normal file
44
front/src/pages/account/login.astro
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
import Layout from "../../layouts/Layout.astro";
|
||||||
|
import PocketBase from 'pocketbase';
|
||||||
|
import AstroUtils from "../../libs/AstroUtils";
|
||||||
|
import Schema from 'models/Schema'
|
||||||
|
|
||||||
|
|
||||||
|
// const usr = await getUser(Astro.cookies)
|
||||||
|
// if (usr) {
|
||||||
|
// return Astro.redirect(route('/', {message: 'Vous êtes déjà connecté !'}))
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
const res = await AstroUtils.wrap(async () => {
|
||||||
|
if (Astro.request.method !== 'POST') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const form = await Astro.request.formData();
|
||||||
|
const request = {
|
||||||
|
email: form.get("username") as String,
|
||||||
|
password: form.get("password") as String
|
||||||
|
}
|
||||||
|
const pb = new PocketBase('http://127.0.0.1:3001');
|
||||||
|
|
||||||
|
const authData = await pb.collection('users').authWithPassword(
|
||||||
|
request.email,
|
||||||
|
request.password,
|
||||||
|
);
|
||||||
|
|
||||||
|
// after the above you can also access the auth data from the authStore
|
||||||
|
console.log(pb.authStore.isValid);
|
||||||
|
console.log(pb.authStore.token);
|
||||||
|
console.log(pb.authStore.model.id);
|
||||||
|
|
||||||
|
})
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout title="login">
|
||||||
|
<form id="account-creation" method="post" enctype="multipart/form-data">
|
||||||
|
<input required name="username" placeholder="Pseudo ou email"/>
|
||||||
|
<input required name="password" type="password" placeholder="Mot de passe" />
|
||||||
|
<button>Connection</button>
|
||||||
|
</form>
|
||||||
|
</Layout>
|
44
front/src/pages/account/register.astro
Normal file
44
front/src/pages/account/register.astro
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
import PocketBase from 'pocketbase';
|
||||||
|
import Layout from '../../layouts/Layout.astro';
|
||||||
|
import AstroUtils from '../../libs/AstroUtils';
|
||||||
|
|
||||||
|
//const connected = await getUser(Astro.cookies)
|
||||||
|
|
||||||
|
// if(connected) {
|
||||||
|
// return Astro.redirect(route('/'))
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
const res = await AstroUtils.wrap(async () => {
|
||||||
|
if (Astro.request.method !== 'POST'){
|
||||||
|
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,
|
||||||
|
emailVisibility: false
|
||||||
|
}
|
||||||
|
const pb = new PocketBase('http://127.0.0.1:3001');
|
||||||
|
|
||||||
|
console.log(request);
|
||||||
|
const record = await pb.collection('users').create(request);
|
||||||
|
console.log(record);
|
||||||
|
|
||||||
|
})
|
||||||
|
---
|
||||||
|
|
||||||
|
<Layout title="register">
|
||||||
|
<form id="account-creation" method="post" enctype="multipart/form-data">
|
||||||
|
<input required name="name" placeholder="Prénom Nom"/>
|
||||||
|
<input required name="username" placeholder="Pseudo"/>
|
||||||
|
<input required name="email" type="email" placeholder="Renseignez votre email" />
|
||||||
|
<input required name="password" type="password" placeholder="Créez un mot de passe" />
|
||||||
|
<input required name="passwordConfirm" type="password" placeholder="Confirmer votre mot de passe" />
|
||||||
|
<button>Créer un compte</button>
|
||||||
|
</form>
|
||||||
|
</Layout>
|
Reference in New Issue
Block a user