From eed4b673c0dad58e13e680166d660c06da5f9bdd Mon Sep 17 00:00:00 2001 From: Denis Lugowski Date: Sun, 6 Apr 2025 09:35:15 +0200 Subject: [PATCH] feat(frontend): Add organization creation, deletion, add better-auth organization plugin --- .vscode/launch.json | 2 +- .../2025-02-07T09-47-53.111Z.sql | 7 - .../2025-03-30T06-50-03.565Z.sql | 13 ++ .../components/CreateOrganizationModal.vue | 117 ++++++++++ .../components/InviteMemberModal.vue | 82 +++++++ legalconsenthub/components/UserMenu.vue | 5 + legalconsenthub/pages/administration.vue | 218 ++++++++++++++++++ legalconsenthub/server/utils/auth.ts | 6 +- legalconsenthub/stores/useUserStore.ts | 39 ++++ legalconsenthub/utils/auth-client.ts | 15 +- legalconsenthub/utils/auth-types.ts | 6 + 11 files changed, 496 insertions(+), 14 deletions(-) delete mode 100644 legalconsenthub/better-auth_migrations/2025-02-07T09-47-53.111Z.sql create mode 100644 legalconsenthub/better-auth_migrations/2025-03-30T06-50-03.565Z.sql create mode 100644 legalconsenthub/components/CreateOrganizationModal.vue create mode 100644 legalconsenthub/components/InviteMemberModal.vue create mode 100644 legalconsenthub/pages/administration.vue create mode 100644 legalconsenthub/stores/useUserStore.ts create mode 100644 legalconsenthub/utils/auth-types.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 25e60d9..b57f7d5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ "type": "chrome", "request": "launch", "name": "client: chrome", - "url": "http://localhost:3000", + "url": "http://localhost:3001", "webRoot": "${workspaceFolder}/legalconsenthub" }, { diff --git a/legalconsenthub/better-auth_migrations/2025-02-07T09-47-53.111Z.sql b/legalconsenthub/better-auth_migrations/2025-02-07T09-47-53.111Z.sql deleted file mode 100644 index 64b3e5e..0000000 --- a/legalconsenthub/better-auth_migrations/2025-02-07T09-47-53.111Z.sql +++ /dev/null @@ -1,7 +0,0 @@ -create table "better_auth_user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null); - -create table "better_auth_session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "better_auth_user" ("id")); - -create table "better_auth_account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "better_auth_user" ("id"), "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null); - -create table "better_auth_verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date, "updatedAt" date) \ No newline at end of file diff --git a/legalconsenthub/better-auth_migrations/2025-03-30T06-50-03.565Z.sql b/legalconsenthub/better-auth_migrations/2025-03-30T06-50-03.565Z.sql new file mode 100644 index 0000000..2316b7d --- /dev/null +++ b/legalconsenthub/better-auth_migrations/2025-03-30T06-50-03.565Z.sql @@ -0,0 +1,13 @@ +create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null); + +create table "session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id"), "activeOrganizationId" text); + +create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id"), "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null); + +create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date, "updatedAt" date); + +create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" date not null, "metadata" text); + +create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id"), "userId" text not null references "user" ("id"), "role" text not null, "createdAt" date not null); + +create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id"), "email" text not null, "role" text, "status" text not null, "expiresAt" date not null, "inviterId" text not null references "user" ("id")); \ No newline at end of file diff --git a/legalconsenthub/components/CreateOrganizationModal.vue b/legalconsenthub/components/CreateOrganizationModal.vue new file mode 100644 index 0000000..b030575 --- /dev/null +++ b/legalconsenthub/components/CreateOrganizationModal.vue @@ -0,0 +1,117 @@ + + + diff --git a/legalconsenthub/components/InviteMemberModal.vue b/legalconsenthub/components/InviteMemberModal.vue new file mode 100644 index 0000000..63cd09d --- /dev/null +++ b/legalconsenthub/components/InviteMemberModal.vue @@ -0,0 +1,82 @@ + + + diff --git a/legalconsenthub/components/UserMenu.vue b/legalconsenthub/components/UserMenu.vue index bee395e..b2eca77 100644 --- a/legalconsenthub/components/UserMenu.vue +++ b/legalconsenthub/components/UserMenu.vue @@ -83,6 +83,11 @@ const items = computed(() => [ label: 'Profile', icon: 'i-lucide-user' }, + { + label: 'Administration', + icon: 'i-lucide-user', + to: '/administration' + }, { label: 'Settings', icon: 'i-lucide-settings', diff --git a/legalconsenthub/pages/administration.vue b/legalconsenthub/pages/administration.vue new file mode 100644 index 0000000..5274c80 --- /dev/null +++ b/legalconsenthub/pages/administration.vue @@ -0,0 +1,218 @@ +