Compare commits
No commits in common. "6fb46b24114aafe9833716242ebc3fe6ee4215dc" and "99f100540ecc01176bdff01db622388d18f8755f" have entirely different histories.
6fb46b2411
...
99f100540e
|
@ -1,12 +1,11 @@
|
||||||
.components__member_card {
|
.components__member_card {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: 1fr auto;
|
grid-template-rows: 1fr 5rem;
|
||||||
width: 16rem;
|
min-width: 15rem;
|
||||||
aspect-ratio: 1;
|
aspect-ratio: 1;
|
||||||
box-shadow: 0 0 0.4rem 0.2rem var(--_translucent);
|
box-shadow: 0 0 0.4rem 0.2rem var(--_translucent);
|
||||||
border: var(--_border-size) solid transparent;
|
border: var(--_border-size) solid transparent;
|
||||||
background-size: 90%;
|
background-size: cover;
|
||||||
background-position-x: center;
|
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
||||||
&:has(a:focus-visible),
|
&:has(a:focus-visible),
|
||||||
|
@ -16,7 +15,6 @@
|
||||||
|
|
||||||
& h3 {
|
& h3 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
& a {
|
& a {
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
":islands/": "./islands/",
|
":islands/": "./islands/",
|
||||||
":src/": "./src/",
|
":src/": "./src/",
|
||||||
":types": "./types.ts",
|
":types": "./types.ts",
|
||||||
"@cohabit/mailer": "jsr:@cohabit/mailer@^0.3.3",
|
"@cohabit/cohamail/": "./packages/@cohabit__cohamail@0.2.1/",
|
||||||
"@cohabit/resources-manager": "jsr:@cohabit/resources-manager@^0.2.1",
|
"@cohabit/ressources_manager/": "./packages/@cohabit__ressources_manager@0.1.3/",
|
||||||
"@deno/gfm": "https://deno.land/x/gfm@0.6.0/mod.ts",
|
"@deno/gfm": "https://deno.land/x/gfm@0.6.0/mod.ts",
|
||||||
"@jotsr/delayed": "jsr:@jotsr/delayed@^2.1.1",
|
"@jotsr/delayed": "jsr:@jotsr/delayed@^2.1.1",
|
||||||
"@jotsr/smart-css-bundler": "jsr:@jotsr/smart-css-bundler@^0.3.0",
|
"@jotsr/smart-css-bundler": "jsr:@jotsr/smart-css-bundler@^0.3.0",
|
||||||
|
@ -59,6 +59,10 @@
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "preact"
|
"jsxImportSource": "preact"
|
||||||
},
|
},
|
||||||
|
"workspaces": [
|
||||||
|
"packages/@cohabit__cohamail@0.2.1",
|
||||||
|
"packages/@cohabit__ressources_manager@0.1.3"
|
||||||
|
],
|
||||||
"unstable": [
|
"unstable": [
|
||||||
"kv"
|
"kv"
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,9 +5,9 @@ import { FreshContext } from '$fresh/server.ts'
|
||||||
import { db } from ':src/db/mod.ts'
|
import { db } from ':src/db/mod.ts'
|
||||||
import { SessionHandlers, SessionStore } from ':src/session/mod.ts'
|
import { SessionHandlers, SessionStore } from ':src/session/mod.ts'
|
||||||
import { respondApi } from ':src/utils.ts'
|
import { respondApi } from ':src/utils.ts'
|
||||||
import { Contact, type Mail, send } from '@cohabit/mailer'
|
import { Contact, type Mail, send } from '@cohabit/cohamail/mod.ts'
|
||||||
import { magicLinkTemplate } from '@cohabit/mailer/templates'
|
import { magicLinkTemplate } from '@cohabit/cohamail/templates/mod.ts'
|
||||||
import { User } from '@cohabit/resources-manager/models'
|
import { User } from '@cohabit/ressources_manager/src/models/mod.ts'
|
||||||
import { sleep } from '@jotsr/delayed'
|
import { sleep } from '@jotsr/delayed'
|
||||||
|
|
||||||
type MagicLinkInfos = {
|
type MagicLinkInfos = {
|
||||||
|
@ -17,7 +17,7 @@ type MagicLinkInfos = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserByMail(email: string): Promise<User | undefined> {
|
export async function getUserByMail(email: string): Promise<User | undefined> {
|
||||||
const [user] = await db.resource.user
|
const [user] = await db.ressource.user
|
||||||
.list((user) => user.mail === email)
|
.list((user) => user.mail === email)
|
||||||
.take(1)
|
.take(1)
|
||||||
.toArray()
|
.toArray()
|
||||||
|
|
|
@ -2,7 +2,8 @@ import { db } from ':src/db/mod.ts'
|
||||||
import type { SessionHandlers } from ':src/session/mod.ts'
|
import type { SessionHandlers } from ':src/session/mod.ts'
|
||||||
import { respondApi } from ':src/utils.ts'
|
import { respondApi } from ':src/utils.ts'
|
||||||
import { getRelyingParty } from ':src/webauthn/mod.ts'
|
import { getRelyingParty } from ':src/webauthn/mod.ts'
|
||||||
import { Credential, Passkey, Ref, User } from '@cohabit/resources-manager/models'
|
import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts'
|
||||||
|
import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts'
|
||||||
import {
|
import {
|
||||||
generateAuthenticationOptions,
|
generateAuthenticationOptions,
|
||||||
verifyAuthenticationResponse,
|
verifyAuthenticationResponse,
|
||||||
|
@ -31,7 +32,7 @@ export const handler: SessionHandlers = {
|
||||||
const { email } = await req.json() as WebAuthnLoginStartPayload
|
const { email } = await req.json() as WebAuthnLoginStartPayload
|
||||||
|
|
||||||
// Get user credentials
|
// Get user credentials
|
||||||
const [user] = await db.resource.user.list((user) => user.mail === email)
|
const [user] = await db.ressource.user.list((user) => user.mail === email)
|
||||||
.take(1).toArray()
|
.take(1).toArray()
|
||||||
// Resolve refs to credentials
|
// Resolve refs to credentials
|
||||||
const resolver = Ref.dbResolver(db)
|
const resolver = Ref.dbResolver(db)
|
||||||
|
@ -120,7 +121,7 @@ export const handler: SessionHandlers = {
|
||||||
const newPasskey = { ...passkey, counter: newCounter }
|
const newPasskey = { ...passkey, counter: newCounter }
|
||||||
|
|
||||||
// Update credential store
|
// Update credential store
|
||||||
const [credential] = await db.resource.credential.list(
|
const [credential] = await db.ressource.credential.list(
|
||||||
(credential) => {
|
(credential) => {
|
||||||
if (credential.category !== 'passkey') {
|
if (credential.category !== 'passkey') {
|
||||||
return false
|
return false
|
||||||
|
@ -130,7 +131,7 @@ export const handler: SessionHandlers = {
|
||||||
).toArray()
|
).toArray()
|
||||||
|
|
||||||
// Save credential to db
|
// Save credential to db
|
||||||
await db.resource.credential.set([
|
await db.ressource.credential.set([
|
||||||
credential.update({ store: newPasskey }),
|
credential.update({ store: newPasskey }),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ import type {
|
||||||
//TODO improve workspace imports
|
//TODO improve workspace imports
|
||||||
import { db } from ':src/db/mod.ts'
|
import { db } from ':src/db/mod.ts'
|
||||||
import { getRelyingParty } from ':src/webauthn/mod.ts'
|
import { getRelyingParty } from ':src/webauthn/mod.ts'
|
||||||
import { Credential, Passkey, Ref, User } from '@cohabit/resources-manager/models'
|
import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts'
|
||||||
|
import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts'
|
||||||
import { encodeBase64 } from '@std/encoding'
|
import { encodeBase64 } from '@std/encoding'
|
||||||
|
|
||||||
type Params = { step: 'start' | 'finish' }
|
type Params = { step: 'start' | 'finish' }
|
||||||
|
@ -41,7 +42,7 @@ export const handler: SessionHandlers = {
|
||||||
|
|
||||||
// Get user credentials
|
// Get user credentials
|
||||||
// Ensure latest user datas
|
// Ensure latest user datas
|
||||||
const dbUser = await db.resource.user.get(user)
|
const dbUser = await db.ressource.user.get(user)
|
||||||
// Resolve refs to credentials
|
// Resolve refs to credentials
|
||||||
const resolver = Ref.dbResolver(db)
|
const resolver = Ref.dbResolver(db)
|
||||||
const credentials = await Promise.all(dbUser.credentials.map(resolver))
|
const credentials = await Promise.all(dbUser.credentials.map(resolver))
|
||||||
|
@ -116,16 +117,16 @@ export const handler: SessionHandlers = {
|
||||||
|
|
||||||
// create and save new Credentials
|
// create and save new Credentials
|
||||||
const credential = Credential.load({ name, category: 'passkey', store })
|
const credential = Credential.load({ name, category: 'passkey', store })
|
||||||
await db.resource.credential.set([credential])
|
await db.ressource.credential.set([credential])
|
||||||
|
|
||||||
// Update user credentials
|
// Update user credentials
|
||||||
// Ensure latest user datas
|
// Ensure latest user datas
|
||||||
const dbUser = await db.resource.user.get(user)
|
const dbUser = await db.ressource.user.get(user)
|
||||||
// Append new credentials
|
// Append new credentials
|
||||||
const credentials = [...dbUser.credentials, credential.toRef()]
|
const credentials = [...dbUser.credentials, credential.toRef()]
|
||||||
const updatedUser = user.update({ credentials })
|
const updatedUser = user.update({ credentials })
|
||||||
// Save user to db
|
// Save user to db
|
||||||
await db.resource.user.set([updatedUser])
|
await db.ressource.user.set([updatedUser])
|
||||||
// Update session
|
// Update session
|
||||||
ctx.state.session.set('user', updatedUser)
|
ctx.state.session.set('user', updatedUser)
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default function Home() {
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h2>Nos membres</h2>
|
<h2>Nos membres</h2>
|
||||||
<AutoGrid columnWidth='16rem' style={{ alignItems: 'center' }}>
|
<AutoGrid columnWidth='15rem' style={{ alignItems: 'center' }}>
|
||||||
<MemberCardList
|
<MemberCardList
|
||||||
limit={4}
|
limit={4}
|
||||||
usePlaceholder={true}
|
usePlaceholder={true}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { fetchCarnet, userToMemberCardProps } from ':src/members/mod.ts'
|
||||||
|
|
||||||
export default async function Member(_: Request, { params, url }: PageProps) {
|
export default async function Member(_: Request, { params, url }: PageProps) {
|
||||||
const uuid = params.id as ReturnType<Crypto['randomUUID']>
|
const uuid = params.id as ReturnType<Crypto['randomUUID']>
|
||||||
const user = await db.resource.user.get({ uuid }).catch(() => undefined)
|
const user = await db.ressource.user.get({ uuid }).catch(() => undefined)
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return <h3>Membre inconnu, peut être serez vous le prochain</h3>
|
return <h3>Membre inconnu, peut être serez vous le prochain</h3>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import LoginForm from ':islands/LoginForm.tsx'
|
import LoginForm from ':islands/LoginForm.tsx'
|
||||||
import PassKeyRegister from ':islands/PassKeyRegister.tsx'
|
import PassKeyRegister from ':islands/PassKeyRegister.tsx'
|
||||||
import type { SessionPageProps } from ':src/session/mod.ts'
|
import type { SessionPageProps } from ':src/session/mod.ts'
|
||||||
import type { User } from '@cohabit/resources-manager/models'
|
import type { User } from '@cohabit/ressources_manager/mod.ts'
|
||||||
import { Button } from 'univoq'
|
import { Button } from 'univoq'
|
||||||
|
|
||||||
export default function Profil({ state }: SessionPageProps) {
|
export default function Profil({ state }: SessionPageProps) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Db } from '@cohabit/resources-manager/db'
|
import { Db, Group } from '@cohabit/ressources_manager/mod.ts'
|
||||||
import { Group, User } from '@cohabit/resources-manager/models'
|
|
||||||
import type { MailAddress } from '@cohabit/resources-manager/types'
|
|
||||||
|
|
||||||
// Import Datas
|
// Import Datas
|
||||||
import { exists } from '$std/fs/exists.ts'
|
import { exists } from '$std/fs/exists.ts'
|
||||||
import { ensureDir } from '$std/fs/mod.ts'
|
import { ensureDir } from '$std/fs/mod.ts'
|
||||||
|
import { User } from '@cohabit/ressources_manager/src/models/mod.ts'
|
||||||
|
import { MailAddress } from '@cohabit/ressources_manager/types.ts'
|
||||||
import groups from ":src/db/mock/groups.json" with { type: 'json' }
|
import groups from ":src/db/mock/groups.json" with { type: 'json' }
|
||||||
import users from ":src/db/mock/users.json" with { type: 'json' }
|
import users from ":src/db/mock/users.json" with { type: 'json' }
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ if (!dbExist) {
|
||||||
// Load groups to DB
|
// Load groups to DB
|
||||||
for (const { name } of groups) {
|
for (const { name } of groups) {
|
||||||
const group = Group.load({ name })
|
const group = Group.load({ name })
|
||||||
db.resource.group.set([group])
|
db.ressource.group.set([group])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load users to DB
|
// Load users to DB
|
||||||
for (const { lastname, firstname, mail, groups: groupNames } of users) {
|
for (const { lastname, firstname, mail, groups: groupNames } of users) {
|
||||||
// Get groups of user
|
// Get groups of user
|
||||||
const groups = await db.resource.group.listRef((group) =>
|
const groups = await db.ressource.group.listRef((group) =>
|
||||||
groupNames.includes(group.name)
|
groupNames.includes(group.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ if (!dbExist) {
|
||||||
groups,
|
groups,
|
||||||
})
|
})
|
||||||
|
|
||||||
db.resource.user.set([user])
|
db.ressource.user.set([user])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { MemberCardProps } from ':components/MemberCard.tsx'
|
import { MemberCardProps } from ':components/MemberCard.tsx'
|
||||||
import { db } from ':src/db/mod.ts'
|
import { db } from ':src/db/mod.ts'
|
||||||
import { Db } from '@cohabit/resources-manager/db'
|
import { Db, Ref, User } from '@cohabit/ressources_manager/mod.ts'
|
||||||
import { Ref, User } from '@cohabit/resources-manager/models'
|
|
||||||
|
|
||||||
export async function fetchCarnet(login: string): Promise<string> {
|
export async function fetchCarnet(login: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue