Skip to content

Commit

Permalink
Merge pull request #1852 from undb-io/release/v1.0.0-3
Browse files Browse the repository at this point in the history
Release version v1.0.0-3
  • Loading branch information
nichenqin authored Aug 6, 2024
2 parents 93292a8 + e7f1d89 commit c249aa2
Show file tree
Hide file tree
Showing 35 changed files with 659 additions and 279 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


## v1.0.0-3


### 🏡 Chore

- Google svg ([58c32b9](https://github.com/undb-io/undb/commit/58c32b9))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-2


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ CREATE TABLE `undb_session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`expires_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `undb_user`(`id`) ON UPDATE no action ON DELETE no action
`space_id` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `undb_user`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`space_id`) REFERENCES `undb_space`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `undb_share` (
Expand Down
22 changes: 21 additions & 1 deletion apps/backend/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "c5657173-e544-40d2-b74c-40eeb7532b85",
"id": "4b64dd29-a974-4cec-9c55-837e0e0acfde",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"undb_api_token": {
Expand Down Expand Up @@ -795,6 +795,13 @@
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"space_id": {
"name": "space_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
Expand All @@ -811,6 +818,19 @@
],
"onDelete": "no action",
"onUpdate": "no action"
},
"undb_session_space_id_undb_space_id_fk": {
"name": "undb_session_space_id_undb_space_id_fk",
"tableFrom": "undb_session",
"tableTo": "undb_space",
"columnsFrom": [
"space_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1722858288654,
"tag": "0000_certain_millenium_guard",
"when": 1722921064579,
"tag": "0000_marvelous_ben_grimm",
"breakpoints": true
}
]
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/constants/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/backend/src/constants/space.constant.ts

This file was deleted.

52 changes: 52 additions & 0 deletions apps/backend/src/modules/auth/auth.provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { LibSQLAdapter } from "@lucia-auth/adapter-sqlite"
import { container, inject } from "@undb/di"
import { sqlite } from "@undb/persistence"
import { Lucia } from "lucia"

export const LUCIA_PROVIDER = Symbol.for("LUCIA_PROVIDER")

const adapter = new LibSQLAdapter(sqlite, {
user: "undb_user",
session: "undb_session",
})

export const lucia = new Lucia(adapter, {
sessionCookie: {
attributes: {
secure: Bun.env.NODE_ENV === "PRODUCTION", // set `Secure` flag in HTTPS
},
},
getSessionAttributes: (attributes) => {
return {
spaceId: attributes.space_id,
}
},
getUserAttributes: (attributes) => {
return {
emailVerified: Boolean(attributes.email_verified),
email: attributes.email,
username: attributes.username,
avatar: attributes.avatar,
}
},
})

declare module "lucia" {
interface Register {
Lucia: typeof lucia
DatabaseSessionAttributes: DatabaseSessionAttributes
DatabaseUserAttributes: {
email: string
email_verified: boolean
username: string
avatar?: string
}
}
interface DatabaseSessionAttributes {
space_id: string
}
}

container.register(LUCIA_PROVIDER, { useValue: lucia })

export const injectLucia = () => inject(LUCIA_PROVIDER)
Loading

0 comments on commit c249aa2

Please sign in to comment.