Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: better auth integration (#466)

Andrej91bb9c2a86c2
diff --git a/apps/api/drizzle/0003_round_human_fly.sql b/apps/api/drizzle/0003_round_human_fly.sql
new file mode 100644
index 000000000..cecc4ec05
--- /dev/null
+++ b/apps/api/drizzle/0003_round_human_fly.sql
@@ -0,0 +1,149 @@
+-- Clear session table since sessions can be recreated
+TRUNCATE TABLE "session";
+--> statement-breakpoint
+CREATE TABLE "account" (
+ "id" text PRIMARY KEY NOT NULL,
+ "account_id" text NOT NULL,
+ "provider_id" text NOT NULL,
+ "user_id" text NOT NULL,
+ "access_token" text,
+ "refresh_token" text,
+ "id_token" text,
+ "access_token_expires_at" timestamp,
+ "refresh_token_expires_at" timestamp,
+ "scope" text,
+ "password" text,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "verification" (
+ "id" text PRIMARY KEY NOT NULL,
+ "identifier" text NOT NULL,
+ "value" text NOT NULL,
+ "expires_at" timestamp NOT NULL,
+ "created_at" timestamp DEFAULT now() NOT NULL,
+ "updated_at" timestamp DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+-- Drop existing foreign key constraints
+ALTER TABLE "activity" DROP CONSTRAINT "activity_user_email_user_email_fk";
+--> statement-breakpoint
+ALTER TABLE "notification" DROP CONSTRAINT "notification_user_email_user_email_fk";
+--> statement-breakpoint
+ALTER TABLE "session" DROP CONSTRAINT "session_user_id_user_id_fk";
+--> statement-breakpoint
+ALTER TABLE "task" DROP CONSTRAINT "task_assignee_email_user_email_fk";
+--> statement-breakpoint
+ALTER TABLE "time_entry" DROP CONSTRAINT "time_entry_user_email_user_email_fk";
+--> statement-breakpoint
+ALTER TABLE "workspace" DROP CONSTRAINT "workspace_owner_email_user_email_fk";
+--> statement-breakpoint
+ALTER TABLE "workspace_member" DROP CONSTRAINT "workspace_member_workspace_id_workspace_id_fk";
+--> statement-breakpoint
+-- Add session columns for better-auth
+ALTER TABLE "session" ADD COLUMN "token" text NOT NULL;--> statement-breakpoint
+ALTER TABLE "session" ADD COLUMN "created_at" timestamp DEFAULT now() NOT NULL;--> statement-breakpoint
+ALTER TABLE "session" ADD COLUMN "updated_at" timestamp DEFAULT now() NOT NULL;--> statement-breakpoint
+ALTER TABLE "session" ADD COLUMN "ip_address" text;--> statement-breakpoint
+ALTER TABLE "session" ADD COLUMN "user_agent" text;--> statement-breakpoint
+-- Add user columns for better-auth (nullable first)
+ALTER TABLE "user" ADD COLUMN "email_verified" boolean;--> statement-breakpoint
+-- Update existing users with default value
+UPDATE "user" SET "email_verified" = false WHERE "email_verified" IS NULL;--> statement-breakpoint
+-- Make email_verified NOT NULL
+ALTER TABLE "user" ALTER COLUMN "email_verified" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "image" text;--> statement-breakpoint
+-- Add user updated_at column as nullable first
+ALTER TABLE "user" ADD COLUMN "updated_at" timestamp;--> statement-breakpoint
+-- Update existing users with default value
+UPDATE "user" SET "updated_at" = NOW() WHERE "updated_at" IS NULL;--> statement-breakpoint
+-- Make updated_at NOT NULL
+ALTER TABLE "user" ALTER COLUMN "updated_at" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "user" ADD COLUMN "is_anonymous" boolean;--> statement-breakpoint
+-- Convert activity.user_email to activity.user_id
+ALTER TABLE "activity" ADD COLUMN "user_id" text;--> statement-breakpoint
+UPDATE "activity" SET "user_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "activity"."user_email"
+) WHERE "user_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "activity" ALTER COLUMN "user_id" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "activity" DROP COLUMN "user_email";--> statement-breakpoint
+-- Convert notification.user_email to notification.user_id
+ALTER TABLE "notification" ADD COLUMN "user_id" text;--> statement-breakpoint
+UPDATE "notification" SET "user_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "notification"."user_email"
+) WHERE "user_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "notification" ALTER COLUMN "user_id" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "notification" DROP COLUMN "user_email";--> statement-breakpoint
+-- Convert task.assignee_email to task.assignee_id
+ALTER TABLE "task" ADD COLUMN "assignee_id" text;--> statement-breakpoint
+UPDATE "task" SET "assignee_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "task"."assignee_email"
+) WHERE "assignee_email" IS NOT NULL AND "assignee_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "task" DROP COLUMN "assignee_email";--> statement-breakpoint
+-- Convert time_entry.user_email to time_entry.user_id
+ALTER TABLE "time_entry" ADD COLUMN "user_id" text;--> statement-breakpoint
+UPDATE "time_entry" SET "user_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "time_entry"."user_email"
+) WHERE "user_email" IS NOT NULL AND "user_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "time_entry" DROP COLUMN "user_email";--> statement-breakpoint
+-- Convert workspace.owner_email to workspace.owner_id
+ALTER TABLE "workspace" ADD COLUMN "owner_id" text;--> statement-breakpoint
+UPDATE "workspace" SET "owner_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "workspace"."owner_email"
+) WHERE "owner_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "workspace" ALTER COLUMN "owner_id" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "workspace" DROP COLUMN "owner_email";--> statement-breakpoint
+-- Convert workspace_member.user_email to workspace_member.user_id
+ALTER TABLE "workspace_member" ADD COLUMN "user_id" text;--> statement-breakpoint
+UPDATE "workspace_member" SET "user_id" = (
+ SELECT u.id
+ FROM "user" u
+ WHERE u.email = "workspace_member"."user_email"
+) WHERE "user_id" IS NULL;--> statement-breakpoint
+ALTER TABLE "workspace_member" ALTER COLUMN "user_id" SET NOT NULL;--> statement-breakpoint
+ALTER TABLE "workspace_member" DROP COLUMN "user_email";--> statement-breakpoint
+-- Migrate existing passwords to account table before dropping user.password
+INSERT INTO "account" (
+ "id",
+ "account_id",
+ "provider_id",
+ "user_id",
+ "password",
+ "created_at",
+ "updated_at"
+)
+SELECT
+ 'acc_' || substr(md5(random()::text || u.id), 1, 21) as id,
+ u.email as account_id,
+ 'credential' as provider_id,
+ u.id as user_id,
+ u.password,
+ NOW() as created_at,
+ NOW() as updated_at
+FROM "user" u
+WHERE u.password IS NOT NULL;--> statement-breakpoint
+-- Add all foreign key constraints
+ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "activity" ADD CONSTRAINT "activity_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
+ALTER TABLE "notification" ADD CONSTRAINT "notification_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
+ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "task" ADD CONSTRAINT "task_assignee_id_user_id_fk" FOREIGN KEY ("assignee_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
+ALTER TABLE "time_entry" ADD CONSTRAINT "time_entry_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
+ALTER TABLE "workspace" ADD CONSTRAINT "workspace_owner_id_user_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "workspace_member" ADD CONSTRAINT "workspace_member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "workspace_member" ADD CONSTRAINT "workspace_member_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+-- Drop user password column (better-auth handles this)
+ALTER TABLE "user" DROP COLUMN "password";--> statement-breakpoint
+-- Add unique constraints
+ALTER TABLE "session" ADD CONSTRAINT "session_token_unique" UNIQUE("token");
diff --git a/apps/api/drizzle/meta/0003_snapshot.json b/apps/api/drizzle/meta/0003_snapshot.json
new file mode 100644
index 000000000..2d7b6a747
--- /dev/null
+++ b/apps/api/drizzle/meta/0003_snapshot.json
@@ -0,0 +1,988 @@
+{
+ "id": "d34d4766-db81-4be9-b4d2-e94653498363",
+ "prevId": "594c9f8c-e00f-4ab1-b4b0-725728bc40eb",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.activity": {
+ "name": "activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "activity_task_id_task_id_fk": {
+ "name": "activity_task_id_task_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "activity_user_id_user_id_fk": {
+ "name": "activity_user_id_user_id_fk",
+ "tableFrom": "activity",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.github_integration": {
+ "name": "github_integration",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_owner": {
+ "name": "repository_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_name": {
+ "name": "repository_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "github_integration_project_id_project_id_fk": {
+ "name": "github_integration_project_id_project_id_fk",
+ "tableFrom": "github_integration",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "github_integration_project_id_unique": {
+ "name": "github_integration_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["project_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_task_id_task_id_fk": {
+ "name": "label_task_id_task_id_fk",
+ "tableFrom": "label",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'info'"
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'Layout'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_public": {
+ "name": "is_public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_workspace_id_workspace_id_fk": {
+ "name": "project_workspace_id_workspace_id_fk",
+ "tableFrom": "project",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task": {
+ "name": "task",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "assignee_id": {
+ "name": "assignee_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'to-do'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'low'"
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "task_project_id_project_id_fk": {
+ "name": "task_project_id_project_id_fk",
+ "tableFrom": "task",
+ "tableTo": "project",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "task_assignee_id_user_id_fk": {
+ "name": "task_assignee_id_user_id_fk",
+ "tableFrom": "task",
+ "tableTo": "user",
+ "columnsFrom": ["assignee_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.time_entry": {
+ "name": "time_entry",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "time_entry_task_id_task_id_fk": {
+ "name": "time_entry_task_id_task_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "task",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "time_entry_user_id_user_id_fk": {
+ "name": "time_entry_user_id_user_id_fk",
+ "tableFrom": "time_entry",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_anonymous": {
+ "name": "is_anonymous",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_owner_id_user_id_fk": {
+ "name": "workspace_owner_id_user_id_fk",
+ "tableFrom": "workspace",
+ "tableTo": "user",
+ "columnsFrom": ["owner_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_member": {
+ "name": "workspace_member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "workspace_member_workspace_id_workspace_id_fk": {
+ "name": "workspace_member_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "workspace",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_member_user_id_user_id_fk": {
+ "name": "workspace_member_user_id_user_id_fk",
+ "tableFrom": "workspace_member",
+ "tableTo": "user",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json
index 06bbe6d7c..83a5e3fa0 100644
--- a/apps/api/drizzle/meta/_journal.json
+++ b/apps/api/drizzle/meta/_journal.json
@@ -22,6 +22,13 @@
"when": 1752666410349,
"tag": "0002_easy_miek",
"breakpoints": true
+ },
+ {
+ "idx": 3,
+ "version": "7",
+ "when": 1755016234993,
+ "tag": "0003_round_human_fly",
+ "breakpoints": true
}
]
}
diff --git a/apps/api/package.json b/apps/api/package.json
index 735d26e69..8579e2ed4 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -12,7 +12,10 @@
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "esbuild src/index.ts --bundle --platform=node --outdir=dist --format=esm --packages=external --external:fs --external:path --external:crypto --external:os --external:util --external:stream --external:buffer --external:events --external:url --external:querystring --external:http --external:https --external:net --external:tls --external:zlib",
- "lint": "biome check --write ."
+ "lint": "biome check --write .",
+ "db:generate": "drizzle-kit generate",
+ "db:migrate": "drizzle-kit migrate",
+ "db:studio": "drizzle-kit studio"
},
"dependencies": {
"@hono/node-server": "^1.18.1",
@@ -22,6 +25,7 @@
"@oslojs/encoding": "^1.1.0",
"@paralleldrive/cuid2": "^2.2.2",
"bcrypt": "^6.0.0",
+ "better-auth": "^1.3.5",
"croner": "^9.1.0",
"dotenv": "^17.2.1",
"drizzle-kit": "^0.31.1",
diff --git a/apps/api/src/activity/controllers/create-activity.ts b/apps/api/src/activity/controllers/create-activity.ts
index af808933b..c84562cd5 100644
--- a/apps/api/src/activity/controllers/create-activity.ts
+++ b/apps/api/src/activity/controllers/create-activity.ts
@@ -4,13 +4,13 @@ import { activityTable } from "../../database/schema";
async function createActivity(
taskId: string,
type: string,
- userEmail: string,
+ userId: string,
content: string,
) {
const activity = await db.insert(activityTable).values({
taskId,
type,
- userEmail,
+ userId,
content,
});
return activity;
diff --git a/apps/api/src/activity/controllers/create-comment.ts b/apps/api/src/activity/controllers/create-comment.ts
index 6e3e5f5d0..c6ce706d8 100644
--- a/apps/api/src/activity/controllers/create-comment.ts
+++ b/apps/api/src/activity/controllers/create-comment.ts
@@ -1,15 +1,11 @@
import db from "../../database";
import { activityTable } from "../../database/schema";
-async function createComment(
- taskId: string,
- userEmail: string,
- content: string,
-) {
+async function createComment(taskId: string, userId: string, content: string) {
const activity = await db.insert(activityTable).values({
taskId,
type: "comment",
- userEmail,
+ userId,
content,
});
return activity;
diff --git a/apps/api/src/activity/controllers/delete-comment.ts b/apps/api/src/activity/controllers/delete-comment.ts
index a1e3d1c2e..5f62e7025 100644
--- a/apps/api/src/activity/controllers/delete-comment.ts
+++ b/apps/api/src/activity/controllers/delete-comment.ts
@@ -2,12 +2,10 @@ import { and, eq } from "drizzle-orm";
import db from "../../database";
import { activityTable } from "../../database/schema";
-async function deleteComment(userEmail: string, id: string) {
+async function deleteComment(userId: string, id: string) {
await db
.delete(activityTable)
- .where(
- and(eq(activityTable.id, id), eq(activityTable.userEmail, userEmail)),
- );
+ .where(and(eq(activityTable.id, id), eq(activityTable.userId, userId)));
}
export default deleteComment;
diff --git a/apps/api/src/activity/controllers/update-comment.ts b/apps/api/src/activity/controllers/update-comment.ts
index ba2ac3e0a..49bcef420 100644
--- a/apps/api/src/activity/controllers/update-comment.ts
+++ b/apps/api/src/activity/controllers/update-comment.ts
@@ -2,13 +2,11 @@ import { and, eq } from "drizzle-orm";
import db from "../../database";
import { activityTable } from "../../database/schema";
-async function updateComment(userEmail: string, id: string, content: string) {
+async function updateComment(userId: string, id: string, content: string) {
return await db
.update(activityTable)
.set({ content })
- .where(
- and(eq(activityTable.id, id), eq(activityTable.userEmail, userEmail)),
- );
+ .where(and(eq(activityTable.id, id), eq(activityTable.userId, userId)));
}
export default updateComment;
diff --git a/apps/api/src/activity/index.ts b/apps/api/src/activity/index.ts
index 4779206bd..a9399f26e 100644
--- a/apps/api/src/activity/index.ts
+++ b/apps/api/src/activity/index.ts
@@ -26,14 +26,14 @@ const activity = new Hono()
z.object({
taskId: z.string(),
type: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
content: z.string(),
}),
),
async (c) => {
- const { taskId, type, userEmail, content } = c.req.valid("json");
+ const { taskId, type, userId, content } = c.req.valid("json");
- const activity = await createActivity(taskId, type, userEmail, content);
+ const activity = await createActivity(taskId, type, userId, content);
return c.json(activity);
},
@@ -45,13 +45,13 @@ const activity = new Hono()
z.object({
taskId: z.string(),
content: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
}),
),
async (c) => {
- const { taskId, content, userEmail } = c.req.valid("json");
+ const { taskId, content, userId } = c.req.valid("json");
- const activity = await createComment(taskId, userEmail, content);
+ const activity = await createComment(taskId, userId, content);
return c.json(activity);
},
@@ -63,13 +63,13 @@ const activity = new Hono()
z.object({
id: z.string(),
content: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
}),
),
async (c) => {
- const { id, content, userEmail } = c.req.valid("json");
+ const { id, content, userId } = c.req.valid("json");
- const activity = await updateComment(userEmail, id, content);
+ const activity = await updateComment(userId, id, content);
return c.json(activity);
},
@@ -80,13 +80,13 @@ const activity = new Hono()
"json",
z.object({
id: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
}),
),
async (c) => {
- const { id, userEmail } = c.req.valid("json");
+ const { id, userId } = c.req.valid("json");
- await deleteComment(userEmail, id);
+ await deleteComment(userId, id);
return c.json({ message: "Comment deleted" });
},
@@ -96,20 +96,20 @@ subscribeToEvent(
"task.created",
async ({
taskId,
- userEmail,
+ userId,
type,
content,
}: {
taskId: string;
- userEmail: string;
+ userId: string;
type: string;
content: string;
}) => {
- if (!userEmail || !taskId || !type || !content) {
+ if (!userId || !taskId || !type || !content) {
return;
}
- await createActivity(taskId, type, userEmail, content);
+ await createActivity(taskId, type, userId, content);
},
);
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
new file mode 100644
index 000000000..9270850a4
--- /dev/null
+++ b/apps/api/src/auth.ts
@@ -0,0 +1,41 @@
+import { betterAuth } from "better-auth";
+import { drizzleAdapter } from "better-auth/adapters/drizzle";
+import { anonymous } from "better-auth/plugins";
+import db, { schema } from "./database";
+import { generateDemoName } from "./utils/generate-demo-name";
+
+import dotenv from "dotenv";
+
+dotenv.config();
+
+export const auth: ReturnType<typeof betterAuth> = betterAuth({
+ baseURL: process.env.BETTER_AUTH_URL || "http://localhost:1337",
+ trustedOrigins: ["http://localhost:5173"], // TODO: Add production URL
+ secret: process.env.JWT_ACCESS_SECRET || "",
+ database: drizzleAdapter(db, {
+ provider: "pg",
+ schema: {
+ ...schema,
+ user: schema.userTable,
+ account: schema.accountTable,
+ session: schema.sessionTable,
+ verification: schema.verificationTable,
+ },
+ }),
+ emailAndPassword: {
+ enabled: true,
+ autoSignIn: true,
+ },
+ socialProviders: {
+ github: {
+ clientId: process.env.GITHUB_CLIENT_ID || "",
+ clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
+ scopes: ["user:email"],
+ },
+ },
+ plugins: [
+ anonymous({
+ generateName: async () => generateDemoName(),
+ }),
+ ],
+});
diff --git a/apps/api/src/database/index.ts b/apps/api/src/database/index.ts
index dbb6fea36..2f9283544 100644
--- a/apps/api/src/database/index.ts
+++ b/apps/api/src/database/index.ts
@@ -2,6 +2,7 @@ import dotenv from "dotenv";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import {
+ accountTableRelations,
activityTableRelations,
githubIntegrationTableRelations,
labelTableRelations,
@@ -11,10 +12,25 @@ import {
taskTableRelations,
timeEntryTableRelations,
userTableRelations,
+ verificationTableRelations,
workspaceTableRelations,
workspaceUserTableRelations,
} from "./relations";
-import * as schema from "./schema";
+import {
+ accountTable,
+ activityTable,
+ githubIntegrationTable,
+ labelTable,
+ notificationTable,
+ projectTable,
+ sessionTable,
+ taskTable,
+ timeEntryTable,
+ userTable,
+ verificationTable,
+ workspaceTable,
+ workspaceUserTable,
+} from "./schema";
dotenv.config();
@@ -24,21 +40,37 @@ const pool = new Pool({
"postgresql://kaneo_user:kaneo_password@localhost:5432/kaneo",
});
+export const schema = {
+ accountTable,
+ activityTable,
+ githubIntegrationTable,
+ labelTable,
+ notificationTable,
+ projectTable,
+ sessionTable,
+ taskTable,
+ timeEntryTable,
+ userTable,
+ verificationTable,
+ workspaceTable,
+ workspaceUserTable,
+ userTableRelations,
+ sessionTableRelations,
+ accountTableRelations,
+ verificationTableRelations,
+ workspaceTableRelations,
+ workspaceUserTableRelations,
+ projectTableRelations,
+ taskTableRelations,
+ timeEntryTableRelations,
+ activityTableRelations,
+ labelTableRelations,
+ notificationTableRelations,
+ githubIntegrationTableRelations,
+};
+
const db = drizzle(pool, {
- schema: {
- ...schema,
- userTableRelations,
- sessionTableRelations,
- workspaceTableRelations,
- workspaceUserTableRelations,
- projectTableRelations,
- taskTableRelations,
- timeEntryTableRelations,
- activityTableRelations,
- labelTableRelations,
- notificationTableRelations,
- githubIntegrationTableRelations,
- },
+ schema: schema,
});
export default db;
diff --git a/apps/api/src/database/relations.ts b/apps/api/src/database/relations.ts
index a97c0570b..9f0c68926 100644
--- a/apps/api/src/database/relations.ts
+++ b/apps/api/src/database/relations.ts
@@ -1,5 +1,6 @@
import { relations } from "drizzle-orm";
import {
+ accountTable,
activityTable,
githubIntegrationTable,
labelTable,
@@ -9,12 +10,14 @@ import {
taskTable,
timeEntryTable,
userTable,
+ verificationTable,
workspaceTable,
workspaceUserTable,
} from "./schema";
export const userTableRelations = relations(userTable, ({ many }) => ({
sessions: many(sessionTable),
+ accounts: many(accountTable),
workspaces: many(workspaceTable),
workspaceMemberships: many(workspaceUserTable),
assignedTasks: many(taskTable),
@@ -30,12 +33,24 @@ export const sessionTableRelations = relations(sessionTable, ({ one }) => ({
}),
}));
+export const accountTableRelations = relations(accountTable, ({ one }) => ({
+ user: one(userTable, {
+ fields: [accountTable.userId],
+ references: [userTable.id],
+ }),
+}));
+
+export const verificationTableRelations = relations(
+ verificationTable,
+ () => ({}),
+);
+
export const workspaceTableRelations = relations(
workspaceTable,
({ one, many }) => ({
owner: one(userTable, {
- fields: [workspaceTable.ownerEmail],
- references: [userTable.email],
+ fields: [workspaceTable.ownerId],
+ references: [userTable.id],
}),
members: many(workspaceUserTable),
projects: many(projectTable),
@@ -49,6 +64,10 @@ export const workspaceUserTableRelations = relations(
fields: [workspaceUserTable.workspaceId],
references: [workspaceTable.id],
}),
+ user: one(userTable, {
+ fields: [workspaceUserTable.userId],
+ references: [userTable.id],
+ }),
}),
);
@@ -70,8 +89,8 @@ export const taskTableRelations = relations(taskTable, ({ one, many }) => ({
references: [projectTable.id],
}),
assignee: one(userTable, {
- fields: [taskTable.userEmail],
- references: [userTable.email],
+ fields: [taskTable.userId],
+ references: [userTable.id],
}),
timeEntries: many(timeEntryTable),
activities: many(activityTable),
@@ -84,8 +103,8 @@ export const timeEntryTableRelations = relations(timeEntryTable, ({ one }) => ({
references: [taskTable.id],
}),
user: one(userTable, {
- fields: [timeEntryTable.userEmail],
- references: [userTable.email],
+ fields: [timeEntryTable.userId],
+ references: [userTable.id],
}),
}));
@@ -95,8 +114,8 @@ export const activityTableRelations = relations(activityTable, ({ one }) => ({
references: [taskTable.id],
}),
user: one(userTable, {
- fields: [activityTable.userEmail],
- references: [userTable.email],
+ fields: [activityTable.userId],
+ references: [userTable.id],
}),
}));
@@ -111,8 +130,8 @@ export const notificationTableRelations = relations(
notificationTable,
({ one }) => ({
user: one(userTable, {
- fields: [notificationTable.userEmail],
- references: [userTable.email],
+ fields: [notificationTable.userId],
+ references: [userTable.id],
}),
}),
);
diff --git a/apps/api/src/database/schema.ts b/apps/api/src/database/schema.ts
index 03509bf93..4ed58f8bb 100644
--- a/apps/api/src/database/schema.ts
+++ b/apps/api/src/database/schema.ts
@@ -12,20 +12,60 @@ export const userTable = pgTable("user", {
.$defaultFn(() => createId())
.primaryKey(),
name: text("name").notNull(),
- password: text("password").notNull(),
email: text("email").notNull().unique(),
+ emailVerified: boolean("email_verified")
+ .$defaultFn(() => false)
+ .notNull(),
+ image: text("image"),
createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" }).defaultNow().notNull(),
+ isAnonymous: boolean("is_anonymous"),
});
export const sessionTable = pgTable("session", {
id: text("id").primaryKey(),
+ expiresAt: timestamp("expires_at", { mode: "date" }).notNull(),
+ token: text("token").notNull().unique(),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" }).defaultNow().notNull(),
+ ipAddress: text("ip_address"),
+ userAgent: text("user_agent"),
userId: text("user_id")
.notNull()
- .references(() => userTable.id, {
- onDelete: "cascade",
- onUpdate: "cascade",
- }),
+ .references(() => userTable.id, { onDelete: "cascade" }),
+});
+
+export const accountTable = pgTable("account", {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ accountId: text("account_id").notNull(),
+ providerId: text("provider_id").notNull(),
+ userId: text("user_id")
+ .notNull()
+ .references(() => userTable.id, { onDelete: "cascade" }),
+ accessToken: text("access_token"),
+ refreshToken: text("refresh_token"),
+ idToken: text("id_token"),
+ accessTokenExpiresAt: timestamp("access_token_expires_at", { mode: "date" }),
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
+ mode: "date",
+ }),
+ scope: text("scope"),
+ password: text("password"),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" }).defaultNow().notNull(),
+});
+
+export const verificationTable = pgTable("verification", {
+ id: text("id")
+ .$defaultFn(() => createId())
+ .primaryKey(),
+ identifier: text("identifier").notNull(),
+ value: text("value").notNull(),
expiresAt: timestamp("expires_at", { mode: "date" }).notNull(),
+ createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
+ updatedAt: timestamp("updated_at", { mode: "date" }).defaultNow().notNull(),
});
export const workspaceTable = pgTable("workspace", {
@@ -34,11 +74,10 @@ export const workspaceTable = pgTable("workspace", {
.primaryKey(),
name: text("name").notNull(),
description: text("description"),
- ownerEmail: text("owner_email")
+ ownerId: text("owner_id")
.notNull()
- .references(() => userTable.email, {
+ .references(() => userTable.id, {
onDelete: "cascade",
- onUpdate: "cascade",
}),
createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
});
@@ -49,9 +88,12 @@ export const workspaceUserTable = pgTable("workspace_member", {
.primaryKey(),
workspaceId: text("workspace_id").references(() => workspaceTable.id, {
onDelete: "cascade",
- onUpdate: "cascade",
}),
- userEmail: text("user_email").notNull(),
+ userId: text("user_id")
+ .notNull()
+ .references(() => userTable.id, {
+ onDelete: "cascade",
+ }),
role: text("role").default("member").notNull(),
joinedAt: timestamp("joined_at", { mode: "date" }).defaultNow().notNull(),
status: text("status").default("pending").notNull(),
@@ -87,7 +129,7 @@ export const taskTable = pgTable("task", {
}),
position: integer("position").default(0),
number: integer("number").default(1),
- userEmail: text("assignee_email").references(() => userTable.email, {
+ userId: text("assignee_id").references(() => userTable.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
@@ -109,7 +151,7 @@ export const timeEntryTable = pgTable("time_entry", {
onDelete: "cascade",
onUpdate: "cascade",
}),
- userEmail: text("user_email").references(() => userTable.email, {
+ userId: text("user_id").references(() => userTable.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
@@ -132,9 +174,9 @@ export const activityTable = pgTable("activity", {
}),
type: text("type").notNull(),
createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
- userEmail: text("user_email")
+ userId: text("user_id")
.notNull()
- .references(() => userTable.email, {
+ .references(() => userTable.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
@@ -160,9 +202,9 @@ export const notificationTable = pgTable("notification", {
id: text("id")
.$defaultFn(() => createId())
.primaryKey(),
- userEmail: text("user_email")
+ userId: text("user_id")
.notNull()
- .references(() => userTable.email, {
+ .references(() => userTable.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
diff --git a/apps/api/src/github-integration/index.ts b/apps/api/src/github-integration/index.ts
index 3954ef12c..499d6b14a 100644
--- a/apps/api/src/github-integration/index.ts
+++ b/apps/api/src/github-integration/index.ts
@@ -24,7 +24,7 @@ if (githubApp) {
subscribeToEvent<{
taskId: string;
- userEmail: string;
+ userId: string;
title: string;
description: string;
priority: string;
@@ -35,7 +35,7 @@ subscribeToEvent<{
subscribeToEvent<{
taskId: string;
- userEmail: string | null;
+ userId: string | null;
oldStatus: string;
newStatus: string;
title: string;
@@ -43,7 +43,7 @@ subscribeToEvent<{
subscribeToEvent<{
taskId: string;
- userEmail: string | null;
+ userId: string | null;
oldPriority: string;
newPriority: string;
title: string;
diff --git a/apps/api/src/github-integration/utils/issue-opened.ts b/apps/api/src/github-integration/utils/issue-opened.ts
index 751e782cc..a02416667 100644
--- a/apps/api/src/github-integration/utils/issue-opened.ts
+++ b/apps/api/src/github-integration/utils/issue-opened.ts
@@ -57,7 +57,7 @@ export const handleIssueOpened: HandlerFunction<
status: taskStatus,
priority: taskPriority,
dueDate: new Date(),
- userEmail: undefined,
+ userId: undefined,
});
const existingLabels =
diff --git a/apps/api/src/github-integration/utils/task-created.ts b/apps/api/src/github-integration/utils/task-created.ts
index d0325f781..d6a01afd6 100644
--- a/apps/api/src/github-integration/utils/task-created.ts
+++ b/apps/api/src/github-integration/utils/task-created.ts
@@ -9,7 +9,7 @@ const githubApp = createGithubApp();
export async function handleTaskCreated(data: {
taskId: string;
- userEmail: string;
+ userId: string;
title: string;
description: string;
priority: string;
@@ -21,7 +21,7 @@ export async function handleTaskCreated(data: {
return;
}
- const { taskId, userEmail, title, description, priority, status, projectId } =
+ const { taskId, userId, title, description, priority, status, projectId } =
data;
if (description?.includes("Created from GitHub issue:")) {
@@ -71,7 +71,7 @@ export async function handleTaskCreated(data: {
- Task ID: ${taskId}
- Status: ${status}
- Priority: ${priority || "Not set"}
-- Assigned to: ${userEmail || "Unassigned"}
+- Assigned to: ${userId || "Unassigned"}
---
*This issue was automatically created from Kaneo task management system.*`,
diff --git a/apps/api/src/github-integration/utils/task-priority-changed.ts b/apps/api/src/github-integration/utils/task-priority-changed.ts
index dcae52de9..befeb4c4b 100644
--- a/apps/api/src/github-integration/utils/task-priority-changed.ts
+++ b/apps/api/src/github-integration/utils/task-priority-changed.ts
@@ -9,7 +9,7 @@ const githubApp = createGithubApp();
export async function handleTaskPriorityChanged(data: {
taskId: string;
- userEmail: string | null;
+ userId: string | null;
oldPriority: string;
newPriority: string;
}) {
diff --git a/apps/api/src/github-integration/utils/task-status-changed.ts b/apps/api/src/github-integration/utils/task-status-changed.ts
index 9f2d6a218..953e86cbe 100644
--- a/apps/api/src/github-integration/utils/task-status-changed.ts
+++ b/apps/api/src/github-integration/utils/task-status-changed.ts
@@ -9,7 +9,7 @@ const githubApp = createGithubApp();
export async function handleTaskStatusChanged(data: {
taskId: string;
- userEmail: string | null;
+ userId: string | null;
oldStatus: string;
newStatus: string;
}) {
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index d2bebc7fa..2a65bba03 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -1,30 +1,36 @@
import { serve } from "@hono/node-server";
+import type { Session, User } from "better-auth/types";
import { Cron } from "croner";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import { Hono } from "hono";
-import { getCookie } from "hono/cookie";
import { cors } from "hono/cors";
+import { HTTPException } from "hono/http-exception";
import activity from "./activity";
+import { auth } from "./auth";
import config from "./config";
import db from "./database";
import githubIntegration from "./github-integration";
import label from "./label";
-import { auth } from "./middlewares/auth";
+
import notification from "./notification";
import project from "./project";
import { getPublicProject } from "./project/controllers/get-public-project";
import search from "./search";
import task from "./task";
import timeEntry from "./time-entry";
-import user from "./user";
-import { validateSessionToken } from "./user/utils/validate-session-token";
import getSettings from "./utils/get-settings";
import purgeDemoData from "./utils/purge-demo-data";
-import setDemoUser from "./utils/set-demo-user";
import workspace from "./workspace";
import workspaceUser from "./workspace-user";
-const app = new Hono<{ Variables: { userEmail: string } }>();
+const app = new Hono<{
+ Variables: {
+ user: User | null;
+ session: Session | null;
+ userId: string;
+ };
+}>();
+
const { isDemoMode } = getSettings();
const corsOrigins = process.env.CORS_ORIGINS
@@ -63,55 +69,28 @@ const publicProjectRoute = app.get("/public-project/:id", async (c) => {
return c.json(project);
});
-const userRoute = app.route("/user", user);
-
-if (!isDemoMode) {
- app.use("*", auth);
-}
-
-if (isDemoMode) {
- new Cron("0 * * * *", async () => {
- await purgeDemoData();
- });
-}
+app.on(["POST", "GET", "PUT", "DELETE"], "/api/auth/*", (c) =>
+ auth.handler(c.req.raw),
+);
app.use("*", async (c, next) => {
- if (isDemoMode) {
- const session = getCookie(c, "session");
-
- if (!session) {
- await setDemoUser(c);
- }
-
- const { user, session: validatedSession } = await validateSessionToken(
- session ?? "",
- );
+ const session = await auth.api.getSession({ headers: c.req.raw.headers });
+ c.set("user", session?.user || null);
+ c.set("session", session?.session || null);
+ c.set("userId", session?.user?.id || "");
- if (!user || !validatedSession) {
- await setDemoUser(c);
- }
-
- c.set("userEmail", user?.email ?? "");
+ if (!session?.user) {
+ throw new HTTPException(401, { message: "Unauthorized" });
}
- await next();
+ return next();
});
-const meRoute = app.get("/me", async (c) => {
- const session = getCookie(c, "session");
-
- if (!session) {
- return c.json({ user: null });
- }
-
- const { user } = await validateSessionToken(session);
-
- if (user === null) {
- return c.json({ user: null });
- }
-
- return c.json({ user });
-});
+if (isDemoMode) {
+ new Cron("0 * * * *", async () => {
+ await purgeDemoData();
+ });
+}
const workspaceRoute = app.route("/workspace", workspace);
const workspaceUserRoute = app.route("/workspace-user", workspaceUser);
@@ -143,13 +122,11 @@ serve(
);
export type AppType =
- | typeof userRoute
| typeof workspaceRoute
| typeof workspaceUserRoute
| typeof projectRoute
| typeof taskRoute
| typeof activityRoute
- | typeof meRoute
| typeof timeEntryRoute
| typeof labelRoute
| typeof notificationRoute
diff --git a/apps/api/src/label/index.ts b/apps/api/src/label/index.ts
index 12e409d38..6c56e6765 100644
--- a/apps/api/src/label/index.ts
+++ b/apps/api/src/label/index.ts
@@ -9,7 +9,7 @@ import updateLabel from "./controllers/update-label";
const label = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get(
diff --git a/apps/api/src/middlewares/auth.ts b/apps/api/src/middlewares/auth.ts
deleted file mode 100644
index 5de7b4ac7..000000000
--- a/apps/api/src/middlewares/auth.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { getCookie, setCookie } from "hono/cookie";
-import { createMiddleware } from "hono/factory";
-import isInSecureMode from "../user/utils/is-in-secure-mode";
-import { validateSessionToken } from "../user/utils/validate-session-token";
-
-export const auth = createMiddleware(async (c, next) => {
- const token = getCookie(c, "session");
-
- if (!token) {
- return c.json({ user: null });
- }
-
- const { user, session: validatedSession } = await validateSessionToken(token);
-
- if (!user || !validatedSession) {
- return c.json({ user: null });
- }
-
- setCookie(c, "session", token, {
- path: "/",
- secure: isInSecureMode(c.req),
- sameSite: "lax",
- expires: validatedSession.expiresAt,
- });
-
- c.set("userEmail", user.email);
-
- return next();
-});
diff --git a/apps/api/src/notification/controllers/clear-notifications.ts b/apps/api/src/notification/controllers/clear-notifications.ts
index 681034a12..5dee21faa 100644
--- a/apps/api/src/notification/controllers/clear-notifications.ts
+++ b/apps/api/src/notification/controllers/clear-notifications.ts
@@ -2,10 +2,10 @@ import { eq } from "drizzle-orm";
import db from "../../database";
import { notificationTable } from "../../database/schema";
-async function clearNotifications(userEmail: string) {
+async function clearNotifications(userId: string) {
await db
.delete(notificationTable)
- .where(eq(notificationTable.userEmail, userEmail));
+ .where(eq(notificationTable.userId, userId));
return { success: true };
}
diff --git a/apps/api/src/notification/controllers/create-notification.ts b/apps/api/src/notification/controllers/create-notification.ts
index afef2f198..fa3b7ef1c 100644
--- a/apps/api/src/notification/controllers/create-notification.ts
+++ b/apps/api/src/notification/controllers/create-notification.ts
@@ -4,14 +4,14 @@ import { notificationTable } from "../../database/schema";
import { publishEvent } from "../../events";
async function createNotification({
- userEmail,
+ userId,
title,
content,
type,
resourceId,
resourceType,
}: {
- userEmail: string;
+ userId: string;
title: string;
content?: string;
type?: string;
@@ -22,7 +22,7 @@ async function createNotification({
.insert(notificationTable)
.values({
id: createId(),
- userEmail,
+ userId,
title,
content: content || "",
type: type || "info",
@@ -34,7 +34,7 @@ async function createNotification({
if (notification) {
await publishEvent("notification.created", {
notificationId: notification.id,
- userEmail,
+ userId,
});
}
diff --git a/apps/api/src/notification/controllers/get-notifications.ts b/apps/api/src/notification/controllers/get-notifications.ts
index 8cf98dcda..f100b9f00 100644
--- a/apps/api/src/notification/controllers/get-notifications.ts
+++ b/apps/api/src/notification/controllers/get-notifications.ts
@@ -2,11 +2,11 @@ import { desc, eq } from "drizzle-orm";
import db from "../../database";
import { notificationTable } from "../../database/schema";
-async function getNotifications(userEmail: string) {
+async function getNotifications(userId: string) {
const notifications = await db
.select()
.from(notificationTable)
- .where(eq(notificationTable.userEmail, userEmail))
+ .where(eq(notificationTable.userId, userId))
.orderBy(desc(notificationTable.createdAt))
.limit(50);
diff --git a/apps/api/src/notification/controllers/mark-all-notifications-as-read.ts b/apps/api/src/notification/controllers/mark-all-notifications-as-read.ts
index b6666cffa..6bcfb4c17 100644
--- a/apps/api/src/notification/controllers/mark-all-notifications-as-read.ts
+++ b/apps/api/src/notification/controllers/mark-all-notifications-as-read.ts
@@ -2,11 +2,11 @@ import { eq } from "drizzle-orm";
import db from "../../database";
import { notificationTable } from "../../database/schema";
-async function markAllNotificationsAsRead(userEmail: string) {
+async function markAllNotificationsAsRead(userId: string) {
await db
.update(notificationTable)
.set({ isRead: true })
- .where(eq(notificationTable.userEmail, userEmail));
+ .where(eq(notificationTable.userId, userId));
return { success: true };
}
diff --git a/apps/api/src/notification/index.ts b/apps/api/src/notification/index.ts
index b7a9f3d46..15be8bbc2 100644
--- a/apps/api/src/notification/index.ts
+++ b/apps/api/src/notification/index.ts
@@ -13,12 +13,12 @@ import markNotificationAsRead from "./controllers/mark-notification-as-read";
const notification = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get("/", async (c) => {
- const userEmail = c.get("userEmail");
- const notifications = await getNotifications(userEmail);
+ const userId = c.get("userId");
+ const notifications = await getNotifications(userId);
return c.json(notifications);
})
.post(
@@ -26,7 +26,7 @@ const notification = new Hono<{
zValidator(
"json",
z.object({
- userEmail: z.string(),
+ userId: z.string(),
title: z.string(),
content: z.string().optional(),
type: z.string().optional(),
@@ -35,11 +35,11 @@ const notification = new Hono<{
}),
),
async (c) => {
- const { userEmail, title, content, type, resourceId, resourceType } =
+ const { userId, title, content, type, resourceId, resourceType } =
c.req.valid("json");
const notification = await createNotification({
- userEmail,
+ userId,
title,
content,
type,
@@ -60,13 +60,13 @@ const notification = new Hono<{
},
)
.patch("/read-all", async (c) => {
- const userEmail = c.get("userEmail");
- const result = await markAllNotificationsAsRead(userEmail);
+ const userId = c.get("userId");
+ const result = await markAllNotificationsAsRead(userId);
return c.json(result);
})
.delete("/clear-all", async (c) => {
- const userEmail = c.get("userEmail");
- const result = await clearNotifications(userEmail);
+ const userId = c.get("userId");
+ const result = await clearNotifications(userId);
return c.json(result);
});
@@ -74,21 +74,21 @@ subscribeToEvent(
"task.created",
async ({
taskId,
- userEmail,
+ userId,
title,
}: {
taskId: string;
- userEmail: string;
+ userId: string;
title?: string;
type: string;
content: string;
}) => {
- if (!userEmail || !taskId) {
+ if (!userId || !taskId) {
return;
}
await createNotification({
- userEmail,
+ userId,
title: "New Task Created",
content: title ? `Task "${title}" was created` : "A new task was created",
type: "task",
@@ -102,15 +102,15 @@ subscribeToEvent(
"workspace.created",
async ({
workspaceId,
- ownerEmail,
+ ownerId,
workspaceName,
- }: { workspaceId: string; ownerEmail: string; workspaceName: string }) => {
- if (!workspaceId || !ownerEmail) {
+ }: { workspaceId: string; ownerId: string; workspaceName: string }) => {
+ if (!workspaceId || !ownerId) {
return;
}
await createNotification({
- userEmail: ownerEmail,
+ userId: ownerId,
title: `Workspace "${workspaceName}" created`,
type: "workspace",
resourceId: workspaceId,
@@ -123,23 +123,23 @@ subscribeToEvent(
"task.status_changed",
async ({
taskId,
- userEmail,
+ userId,
oldStatus,
newStatus,
title,
}: {
taskId: string;
- userEmail: string | null;
+ userId: string | null;
oldStatus: string;
newStatus: string;
title: string;
}) => {
- if (!taskId || !userEmail) {
+ if (!taskId || !userId) {
return;
}
await createNotification({
- userEmail,
+ userId,
title: `Task "${title}" moved from ${oldStatus.replace(/-/g, " ")} to ${newStatus.replace(/-/g, " ")}`,
type: "task",
resourceId: taskId,
@@ -164,7 +164,7 @@ subscribeToEvent(
}
await createNotification({
- userEmail: newAssignee,
+ userId: newAssignee,
title: "Task Assigned to You",
content: `You have been assigned to task "${title}"`,
type: "task",
@@ -179,15 +179,15 @@ subscribeToEvent(
async ({
timeEntryId,
taskId,
- userEmail,
+ userId,
}: {
timeEntryId: string;
taskId: string;
- userEmail: string;
+ userId: string;
type: string;
content: string;
}) => {
- if (!timeEntryId || !taskId || !userEmail) {
+ if (!timeEntryId || !taskId || !userId) {
return;
}
@@ -197,7 +197,7 @@ subscribeToEvent(
if (task) {
await createNotification({
- userEmail,
+ userId,
title: "Time Tracking Started",
content: `You started tracking time for task "${task.title}"`,
type: "time-entry",
diff --git a/apps/api/src/search/controllers/global-search.ts b/apps/api/src/search/controllers/global-search.ts
index 3108280e3..32668208b 100644
--- a/apps/api/src/search/controllers/global-search.ts
+++ b/apps/api/src/search/controllers/global-search.ts
@@ -11,7 +11,8 @@ import {
type SearchParams = {
query: string;
- userEmail: string;
+ userEmail?: string;
+ userId?: string;
type?:
| "all"
| "tasks"
@@ -34,7 +35,7 @@ type SearchResult = {
projectName?: string;
workspaceId?: string;
workspaceName?: string;
- userEmail?: string;
+ userId?: string;
userName?: string;
createdAt: Date;
relevanceScore: number;
@@ -51,6 +52,7 @@ async function globalSearch(params: SearchParams): Promise<{
}> {
const {
query,
+ userId,
userEmail,
type = "all",
workspaceId,
@@ -58,10 +60,27 @@ async function globalSearch(params: SearchParams): Promise<{
limit = 20,
} = params;
+ let resolvedUserId = userId;
+ if (!resolvedUserId && userEmail) {
+ const user = await db
+ .select({ id: userTable.id })
+ .from(userTable)
+ .where(eq(userTable.email, userEmail))
+ .limit(1);
+
+ if (user.length > 0 && user[0]) {
+ resolvedUserId = user[0].id;
+ }
+ }
+
+ if (!resolvedUserId) {
+ return { results: [], totalCount: 0, searchQuery: query };
+ }
+
const userWorkspaces = await db
.select({ workspaceId: workspaceUserTable.workspaceId })
.from(workspaceUserTable)
- .where(eq(workspaceUserTable.userEmail, userEmail));
+ .where(eq(workspaceUserTable.userId, resolvedUserId));
const accessibleWorkspaceIds = userWorkspaces
.map((w) => w.workspaceId)
@@ -97,7 +116,7 @@ async function globalSearch(params: SearchParams): Promise<{
projectSlug: projectTable.slug,
workspaceId: projectTable.workspaceId,
workspaceName: workspaceTable.name,
- userEmail: taskTable.userEmail,
+ userId: taskTable.userId,
userName: userTable.name,
createdAt: taskTable.createdAt,
taskNumber: taskTable.number,
@@ -108,7 +127,7 @@ async function globalSearch(params: SearchParams): Promise<{
.from(taskTable)
.leftJoin(projectTable, eq(taskTable.projectId, projectTable.id))
.leftJoin(workspaceTable, eq(projectTable.workspaceId, workspaceTable.id))
- .leftJoin(userTable, eq(taskTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(taskTable.userId, userTable.id))
.where(
and(
workspaceFilter,
@@ -135,7 +154,7 @@ async function globalSearch(params: SearchParams): Promise<{
projectSlug: task.projectSlug || undefined,
workspaceId: task.workspaceId || undefined,
workspaceName: task.workspaceName || undefined,
- userEmail: task.userEmail || undefined,
+ userId: task.userId || undefined,
userName: task.userName || undefined,
createdAt: task.createdAt,
relevanceScore: task.relevanceScore,
@@ -212,7 +231,7 @@ async function globalSearch(params: SearchParams): Promise<{
id: workspaceTable.id,
name: workspaceTable.name,
description: workspaceTable.description,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
createdAt: workspaceTable.createdAt,
relevanceScore: workspaceRelevanceScore.as("relevanceScore"),
})
@@ -243,7 +262,7 @@ async function globalSearch(params: SearchParams): Promise<{
description: workspace.description || undefined,
workspaceId: workspace.id,
workspaceName: workspace.name,
- userEmail: workspace.ownerEmail,
+ userId: workspace.ownerId,
createdAt: workspace.createdAt,
relevanceScore: workspace.relevanceScore,
});
@@ -272,7 +291,7 @@ async function globalSearch(params: SearchParams): Promise<{
projectSlug: projectTable.slug,
workspaceId: projectTable.workspaceId,
workspaceName: workspaceTable.name,
- userEmail: activityTable.userEmail,
+ userId: activityTable.userId,
userName: userTable.name,
createdAt: activityTable.createdAt,
relevanceScore: activityRelevanceScore.as("relevanceScore"),
@@ -281,7 +300,7 @@ async function globalSearch(params: SearchParams): Promise<{
.leftJoin(taskTable, eq(activityTable.taskId, taskTable.id))
.leftJoin(projectTable, eq(taskTable.projectId, projectTable.id))
.leftJoin(workspaceTable, eq(projectTable.workspaceId, workspaceTable.id))
- .leftJoin(userTable, eq(activityTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(activityTable.userId, userTable.id))
.where(
and(
workspaceFilter,
@@ -312,7 +331,7 @@ async function globalSearch(params: SearchParams): Promise<{
projectSlug: activity.projectSlug || undefined,
workspaceId: activity.workspaceId || undefined,
workspaceName: activity.workspaceName || undefined,
- userEmail: activity.userEmail || undefined,
+ userId: activity.userId || undefined,
userName: activity.userName || undefined,
createdAt: activity.createdAt,
relevanceScore: activity.relevanceScore,
diff --git a/apps/api/src/search/index.ts b/apps/api/src/search/index.ts
index bf7293ed5..679ee676c 100644
--- a/apps/api/src/search/index.ts
+++ b/apps/api/src/search/index.ts
@@ -5,7 +5,7 @@ import globalSearch from "./controllers/global-search";
const search = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>().get(
"/",
@@ -27,14 +27,17 @@ const search = new Hono<{
workspaceId: z.string().optional(),
projectId: z.string().optional(),
limit: z.coerce.number().min(1).max(50).optional().default(20),
+ userEmail: z.email().optional(),
}),
),
async (c) => {
- const { q, type, workspaceId, projectId, limit } = c.req.valid("query");
- const userEmail = c.get("userEmail");
+ const { q, type, workspaceId, projectId, limit, userEmail } =
+ c.req.valid("query");
+ const userId = c.get("userId");
const results = await globalSearch({
query: q,
+ userId,
userEmail,
type,
workspaceId,
diff --git a/apps/api/src/task/controllers/create-task.ts b/apps/api/src/task/controllers/create-task.ts
index d261907f0..564e02491 100644
--- a/apps/api/src/task/controllers/create-task.ts
+++ b/apps/api/src/task/controllers/create-task.ts
@@ -7,7 +7,7 @@ import getNextTaskNumber from "./get-next-task-number";
async function createTask({
projectId,
- userEmail,
+ userId,
title,
status,
dueDate,
@@ -15,7 +15,7 @@ async function createTask({
priority,
}: {
projectId: string;
- userEmail?: string;
+ userId?: string;
title: string;
status: string;
dueDate?: Date;
@@ -25,7 +25,7 @@ async function createTask({
const [assignee] = await db
.select({ name: userTable.name })
.from(userTable)
- .where(eq(userTable.email, userEmail ?? ""));
+ .where(eq(userTable.id, userId ?? ""));
const nextTaskNumber = await getNextTaskNumber(projectId);
@@ -33,7 +33,7 @@ async function createTask({
.insert(taskTable)
.values({
projectId,
- userEmail: userEmail || null,
+ userId: userId || null,
title: title || "",
status: status || "",
dueDate: dueDate || new Date(),
@@ -52,7 +52,7 @@ async function createTask({
await publishEvent("task.created", {
...createdTask,
taskId: createdTask.id,
- userEmail: createdTask.userEmail ?? "",
+ userId: createdTask.userId ?? "",
type: "task",
content: "created the task",
});
diff --git a/apps/api/src/task/controllers/export-tasks.ts b/apps/api/src/task/controllers/export-tasks.ts
index 5d814f4a1..8758ff45f 100644
--- a/apps/api/src/task/controllers/export-tasks.ts
+++ b/apps/api/src/task/controllers/export-tasks.ts
@@ -25,12 +25,12 @@ async function exportTasks(projectId: string) {
dueDate: taskTable.dueDate,
position: taskTable.position,
createdAt: taskTable.createdAt,
- userEmail: taskTable.userEmail,
+ userId: taskTable.userId,
assigneeName: userTable.name,
- assigneeEmail: userTable.email,
+ assigneeId: userTable.id,
})
.from(taskTable)
- .leftJoin(userTable, eq(taskTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(taskTable.userId, userTable.id))
.where(eq(taskTable.projectId, projectId))
.orderBy(taskTable.position);
@@ -47,7 +47,7 @@ async function exportTasks(projectId: string) {
status: task.status,
priority: task.priority || "low",
dueDate: task.dueDate ? new Date(task.dueDate).toISOString() : null,
- userEmail: task.userEmail || null,
+ userId: task.userId || null,
})),
};
}
diff --git a/apps/api/src/task/controllers/get-task.ts b/apps/api/src/task/controllers/get-task.ts
index 38d276858..f50f7a37a 100644
--- a/apps/api/src/task/controllers/get-task.ts
+++ b/apps/api/src/task/controllers/get-task.ts
@@ -15,13 +15,13 @@ async function getTask(taskId: string) {
dueDate: taskTable.dueDate,
position: taskTable.position,
createdAt: taskTable.createdAt,
- userEmail: taskTable.userEmail,
+ userId: taskTable.userId,
assigneeName: userTable.name,
- assigneeEmail: userTable.email,
+ assigneeId: userTable.id,
projectId: taskTable.projectId,
})
.from(taskTable)
- .leftJoin(userTable, eq(taskTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(taskTable.userId, userTable.id))
.where(eq(taskTable.id, taskId))
.limit(1);
diff --git a/apps/api/src/task/controllers/get-tasks.ts b/apps/api/src/task/controllers/get-tasks.ts
index 8022ef8f1..57fb0912e 100644
--- a/apps/api/src/task/controllers/get-tasks.ts
+++ b/apps/api/src/task/controllers/get-tasks.ts
@@ -32,13 +32,13 @@ async function getTasks(projectId: string) {
dueDate: taskTable.dueDate,
position: taskTable.position,
createdAt: taskTable.createdAt,
- userEmail: taskTable.userEmail,
+ userId: taskTable.userId,
assigneeName: userTable.name,
- assigneeEmail: userTable.email,
+ assigneeId: userTable.id,
projectId: taskTable.projectId,
})
.from(taskTable)
- .leftJoin(userTable, eq(taskTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(taskTable.userId, userTable.id))
.leftJoin(projectTable, eq(taskTable.projectId, projectTable.id))
.where(eq(taskTable.projectId, projectId))
.orderBy(taskTable.position);
diff --git a/apps/api/src/task/controllers/import-tasks.ts b/apps/api/src/task/controllers/import-tasks.ts
index f16820716..2ae3bd598 100644
--- a/apps/api/src/task/controllers/import-tasks.ts
+++ b/apps/api/src/task/controllers/import-tasks.ts
@@ -11,7 +11,7 @@ type ImportTask = {
status: string;
priority?: string;
dueDate?: string;
- userEmail?: string | null;
+ userId?: string | null;
};
async function importTasks(projectId: string, tasksToImport: ImportTask[]) {
@@ -36,7 +36,7 @@ async function importTasks(projectId: string, tasksToImport: ImportTask[]) {
.insert(taskTable)
.values({
projectId,
- userEmail: taskData.userEmail || null,
+ userId: taskData.userId || null,
title: taskData.title,
status: taskData.status,
dueDate: taskData.dueDate ? new Date(taskData.dueDate) : null,
@@ -49,7 +49,7 @@ async function importTasks(projectId: string, tasksToImport: ImportTask[]) {
if (createdTask) {
await publishEvent("task.created", {
taskId: createdTask.id,
- userEmail: createdTask.userEmail ?? "",
+ userId: createdTask.userId ?? "",
type: "create",
content: "imported the task",
});
diff --git a/apps/api/src/task/controllers/update-task-status.ts b/apps/api/src/task/controllers/update-task-status.ts
index 3fb5ba3ff..11ef459b6 100644
--- a/apps/api/src/task/controllers/update-task-status.ts
+++ b/apps/api/src/task/controllers/update-task-status.ts
@@ -5,11 +5,11 @@ import { taskTable } from "../../database/schema";
async function updateTaskStatus({
id,
status,
- userEmail,
-}: { id: string; status: string; userEmail: string }) {
+ userId,
+}: { id: string; status: string; userId: string }) {
await db
.update(taskTable)
- .set({ status, userEmail })
+ .set({ status, userId })
.where(eq(taskTable.id, id));
}
diff --git a/apps/api/src/task/controllers/update-task.ts b/apps/api/src/task/controllers/update-task.ts
index 3f2b09574..a1f333a6c 100644
--- a/apps/api/src/task/controllers/update-task.ts
+++ b/apps/api/src/task/controllers/update-task.ts
@@ -13,7 +13,7 @@ async function updateTask(
description: string,
priority: string,
position: number,
- userEmail?: string,
+ userId?: string,
) {
const existingTask = await db.query.taskTable.findFirst({
where: eq(taskTable.id, id),
@@ -35,7 +35,7 @@ async function updateTask(
description,
priority,
position,
- userEmail: userEmail || null,
+ userId: userId || null,
})
.where(eq(taskTable.id, id))
.returning();
@@ -49,7 +49,7 @@ async function updateTask(
if (existingTask.status !== status) {
await publishEvent("task.status_changed", {
taskId: updatedTask.id,
- userEmail: updatedTask.userEmail,
+ userId: updatedTask.userId,
oldStatus: existingTask.status,
newStatus: status,
title: updatedTask.title,
@@ -59,17 +59,17 @@ async function updateTask(
if (existingTask.priority !== priority) {
await publishEvent("task.priority_changed", {
taskId: updatedTask.id,
- userEmail: updatedTask.userEmail,
+ userId: updatedTask.userId,
oldPriority: existingTask.priority,
newPriority: priority,
title: updatedTask.title,
});
}
- if (existingTask.userEmail !== userEmail) {
+ if (existingTask.userId !== userId) {
await publishEvent("task.assignee_changed", {
taskId: updatedTask.id,
- newAssignee: userEmail,
+ newAssignee: userId,
title: updatedTask.title,
});
}
diff --git a/apps/api/src/task/index.ts b/apps/api/src/task/index.ts
index 05440b7e2..5ee6180d4 100644
--- a/apps/api/src/task/index.ts
+++ b/apps/api/src/task/index.ts
@@ -11,7 +11,7 @@ import updateTask from "./controllers/update-task";
const task = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get(
@@ -35,17 +35,17 @@ const task = new Hono<{
dueDate: z.string(),
priority: z.string(),
status: z.string(),
- userEmail: z.string().optional(),
+ userId: z.string().optional(),
}),
),
async (c) => {
const { projectId } = c.req.param();
- const { title, description, dueDate, priority, status, userEmail } =
+ const { title, description, dueDate, priority, status, userId } =
c.req.valid("json");
const task = await createTask({
projectId,
- userEmail,
+ userId,
title,
description,
dueDate: new Date(dueDate),
@@ -76,7 +76,7 @@ const task = new Hono<{
status: z.string(),
projectId: z.string(),
position: z.number(),
- userEmail: z.string().optional(),
+ userId: z.string().optional(),
}),
),
async (c) => {
@@ -89,7 +89,7 @@ const task = new Hono<{
status,
projectId,
position,
- userEmail,
+ userId,
} = c.req.valid("json");
const task = await updateTask(
@@ -101,7 +101,7 @@ const task = new Hono<{
description,
priority,
position,
- userEmail,
+ userId,
);
return c.json(task);
@@ -131,7 +131,7 @@ const task = new Hono<{
status: z.string(),
priority: z.string().optional(),
dueDate: z.string().optional(),
- userEmail: z.string().nullable().optional(),
+ userId: z.string().nullable().optional(),
}),
),
}),
diff --git a/apps/api/src/time-entry/controllers/create-time-entry.ts b/apps/api/src/time-entry/controllers/create-time-entry.ts
index 5d89e5676..1fda88ea9 100644
--- a/apps/api/src/time-entry/controllers/create-time-entry.ts
+++ b/apps/api/src/time-entry/controllers/create-time-entry.ts
@@ -6,14 +6,14 @@ import { publishEvent } from "../../events";
async function createTimeEntry({
taskId,
- userEmail,
+ userId,
description,
startTime,
endTime,
duration,
}: {
taskId: string;
- userEmail: string;
+ userId: string;
description?: string;
startTime: Date;
endTime?: Date;
@@ -24,7 +24,7 @@ async function createTimeEntry({
.values({
id: createId(),
taskId,
- userEmail,
+ userId,
description: description || "",
startTime,
endTime: endTime || null,
@@ -41,7 +41,7 @@ async function createTimeEntry({
await publishEvent("time-entry.created", {
timeEntryId: createdTimeEntry.id,
taskId: createdTimeEntry.taskId,
- userEmail,
+ userId,
type: "create",
content: "started time tracking",
});
diff --git a/apps/api/src/time-entry/controllers/get-time-entries.ts b/apps/api/src/time-entry/controllers/get-time-entries.ts
index d157052e1..a625391ec 100644
--- a/apps/api/src/time-entry/controllers/get-time-entries.ts
+++ b/apps/api/src/time-entry/controllers/get-time-entries.ts
@@ -7,7 +7,7 @@ async function getTimeEntriesByTaskId(taskId: string) {
.select({
id: timeEntryTable.id,
taskId: timeEntryTable.taskId,
- userEmail: timeEntryTable.userEmail,
+ userId: timeEntryTable.userId,
userName: userTable.name,
description: timeEntryTable.description,
startTime: timeEntryTable.startTime,
@@ -16,7 +16,7 @@ async function getTimeEntriesByTaskId(taskId: string) {
createdAt: timeEntryTable.createdAt,
})
.from(timeEntryTable)
- .leftJoin(userTable, eq(timeEntryTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(timeEntryTable.userId, userTable.id))
.where(eq(timeEntryTable.taskId, taskId))
.orderBy(timeEntryTable.startTime);
diff --git a/apps/api/src/time-entry/index.ts b/apps/api/src/time-entry/index.ts
index bf99fd533..a1c280781 100644
--- a/apps/api/src/time-entry/index.ts
+++ b/apps/api/src/time-entry/index.ts
@@ -8,7 +8,7 @@ import updateTimeEntry from "./controllers/update-time-entry";
const timeEntry = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get(
@@ -37,11 +37,11 @@ const timeEntry = new Hono<{
),
async (c) => {
const { taskId, description, startTime } = c.req.valid("json");
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
const timeEntry = await createTimeEntry({
taskId,
- userEmail,
+ userId,
description,
startTime: new Date(startTime),
});
diff --git a/apps/api/src/user/controllers/sign-in.ts b/apps/api/src/user/controllers/sign-in.ts
deleted file mode 100644
index db3f1d68a..000000000
--- a/apps/api/src/user/controllers/sign-in.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import bcrypt from "bcrypt";
-import { HTTPException } from "hono/http-exception";
-import db from "../../database";
-
-async function signIn(email: string, password: string) {
- const user = await db.query.userTable.findFirst({
- where: (users, { eq }) => eq(users.email, email),
- });
-
- if (!user) {
- throw new HTTPException(404, {
- message: "User not found",
- });
- }
-
- const isPasswordValid = await bcrypt.compare(password, user.password);
-
- if (!isPasswordValid) {
- throw new HTTPException(401, {
- message: "Invalid credentials",
- });
- }
-
- return {
- id: user.id,
- email: user.email,
- name: user.name,
- };
-}
-
-export default signIn;
diff --git a/apps/api/src/user/controllers/sign-up.ts b/apps/api/src/user/controllers/sign-up.ts
deleted file mode 100644
index 1104f72ff..000000000
--- a/apps/api/src/user/controllers/sign-up.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import bcrypt from "bcrypt";
-import { HTTPException } from "hono/http-exception";
-import db from "../../database";
-import { userTable } from "../../database/schema";
-import { publishEvent } from "../../events";
-import getSettings from "../../utils/get-settings";
-
-async function signUp(email: string, password: string, name: string) {
- const { disableRegistration, isDemoMode } = getSettings();
-
- if (disableRegistration && !isDemoMode) {
- throw new HTTPException(400, {
- message: "Registration is disabled on this instance",
- });
- }
-
- const isEmailTaken = Boolean(
- await db.query.userTable.findFirst({
- where: (users, { eq }) => eq(users.email, email),
- }),
- );
-
- if (isEmailTaken) {
- throw new HTTPException(400, {
- message: "Email taken",
- });
- }
-
- const hashedPassword = await bcrypt.hash(password, 10);
-
- const [user] = await db
- .insert(userTable)
- .values({ email, name, password: hashedPassword })
- .returning();
-
- if (!user) {
- throw new HTTPException(500, {
- message: "Failed to create an account",
- });
- }
-
- publishEvent("user.signed_up", {
- email: user.email,
- });
-
- return {
- id: user.id,
- email: user.email,
- name: user.name,
- };
-}
-
-export default signUp;
diff --git a/apps/api/src/user/index.ts b/apps/api/src/user/index.ts
deleted file mode 100644
index cba2e8cc5..000000000
--- a/apps/api/src/user/index.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import { zValidator } from "@hono/zod-validator";
-import { Hono } from "hono";
-import { deleteCookie, getCookie, setCookie } from "hono/cookie";
-import { z } from "zod";
-import signIn from "./controllers/sign-in";
-import signUp from "./controllers/sign-up";
-import createSession from "./utils/create-session";
-import generateSessionToken from "./utils/generate-session-token";
-import invalidateSession from "./utils/invalidate-session";
-import isInSecureMode from "./utils/is-in-secure-mode";
-
-const user = new Hono()
- .post(
- "/sign-in",
- zValidator("json", z.object({ email: z.string(), password: z.string() })),
- async (c) => {
- const { email, password } = c.req.valid("json");
-
- const user = await signIn(email, password);
-
- const token = generateSessionToken();
- const session = await createSession(token, user.id);
-
- setCookie(c, "session", token, {
- path: "/",
- secure: isInSecureMode(c.req),
- sameSite: "lax",
- expires: session.expiresAt,
- });
-
- return c.json(user);
- },
- )
- .post(
- "/sign-up",
- zValidator(
- "json",
- z.object({ email: z.string(), password: z.string(), name: z.string() }),
- ),
- async (c) => {
- const { email, password, name } = c.req.valid("json");
-
- const user = await signUp(email, password, name);
-
- const token = generateSessionToken();
- const session = await createSession(token, user.id);
-
- setCookie(c, "session", token, {
- path: "/",
- secure: isInSecureMode(c.req),
- sameSite: "lax",
- expires: session.expiresAt,
- });
-
- return c.json(user);
- },
- )
- .post("/sign-out", async (c) => {
- const token = getCookie(c, "session");
-
- if (!token) {
- return c.json({ message: "No session token found" }, 401);
- }
-
- await invalidateSession(token);
- deleteCookie(c, "session");
-
- return c.json({ message: "Signed out" });
- });
-
-export default user;
diff --git a/apps/api/src/user/utils/create-session.ts b/apps/api/src/user/utils/create-session.ts
deleted file mode 100644
index 6d792838b..000000000
--- a/apps/api/src/user/utils/create-session.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { sha256 } from "@oslojs/crypto/sha2";
-import { encodeHexLowerCase } from "@oslojs/encoding";
-import db from "../../database";
-import { sessionTable } from "../../database/schema";
-
-async function createSession(token: string, userId: string) {
- const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
- const session = {
- id: sessionId,
- userId,
- expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30),
- };
- await db.insert(sessionTable).values(session);
- return session;
-}
-
-export default createSession;
diff --git a/apps/api/src/user/utils/generate-session-token.ts b/apps/api/src/user/utils/generate-session-token.ts
deleted file mode 100644
index a9d60d886..000000000
--- a/apps/api/src/user/utils/generate-session-token.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { encodeBase32LowerCaseNoPadding } from "@oslojs/encoding";
-
-function generateSessionToken(): string {
- const bytes = new Uint8Array(20);
- crypto.getRandomValues(bytes);
- const token = encodeBase32LowerCaseNoPadding(bytes);
- return token;
-}
-
-export default generateSessionToken;
diff --git a/apps/api/src/user/utils/invalidate-session.ts b/apps/api/src/user/utils/invalidate-session.ts
deleted file mode 100644
index 6f851bd35..000000000
--- a/apps/api/src/user/utils/invalidate-session.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { eq } from "drizzle-orm";
-import db from "../../database";
-import { sessionTable } from "../../database/schema";
-
-async function invalidateSession(sessionId: string) {
- await db.delete(sessionTable).where(eq(sessionTable.id, sessionId));
-}
-
-export default invalidateSession;
diff --git a/apps/api/src/user/utils/is-in-secure-mode.ts b/apps/api/src/user/utils/is-in-secure-mode.ts
deleted file mode 100644
index e5c67dd1f..000000000
--- a/apps/api/src/user/utils/is-in-secure-mode.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type { Context } from "hono";
-
-export default function isInSecureMode(request: Context["req"]) {
- return request.header("x-forwarded-proto") === "https";
-}
diff --git a/apps/api/src/user/utils/validate-session-token.ts b/apps/api/src/user/utils/validate-session-token.ts
deleted file mode 100644
index 281309bfd..000000000
--- a/apps/api/src/user/utils/validate-session-token.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { sha256 } from "@oslojs/crypto/sha2";
-import { encodeHexLowerCase } from "@oslojs/encoding";
-import { eq } from "drizzle-orm";
-import db from "../../database";
-import { sessionTable, userTable } from "../../database/schema";
-
-export async function validateSessionToken(token: string) {
- const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
- const sessions = await db
- .select({ user: userTable, session: sessionTable })
- .from(sessionTable)
- .innerJoin(userTable, eq(sessionTable.userId, userTable.id))
- .where(eq(sessionTable.id, sessionId));
-
- if (sessions.length < 1 || !sessions[0]) {
- return { session: null, user: null };
- }
-
- const { user, session } = sessions[0];
-
- const isSessionExpired = Date.now() >= session.expiresAt.getTime();
-
- if (isSessionExpired) {
- await db.delete(sessionTable).where(eq(sessionTable.id, session.id));
- return { session: null, user: null };
- }
-
- const isSessionHalfWayExpired =
- Date.now() >= session.expiresAt.getTime() - 1000 * 60 * 60 * 24 * 15;
-
- if (isSessionHalfWayExpired) {
- session.expiresAt = new Date(Date.now() + 1000 * 60 * 60 * 24 * 30);
- await db
- .update(sessionTable)
- .set({
- expiresAt: session.expiresAt,
- })
- .where(eq(sessionTable.id, session.id));
- }
-
- return { session, user };
-}
diff --git a/apps/api/src/utils/create-demo-user.ts b/apps/api/src/utils/create-demo-user.ts
deleted file mode 100644
index 2e2135d85..000000000
--- a/apps/api/src/utils/create-demo-user.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { createId } from "@paralleldrive/cuid2";
-import bcrypt from "bcrypt";
-import db from "../database";
-import { userTable } from "../database/schema";
-import createSession from "../user/utils/create-session";
-import generateSessionToken from "../user/utils/generate-session-token";
-import { generateDemoName } from "./generate-demo-name";
-export async function createDemoUser() {
- const demoId = createId();
- const demoName = generateDemoName();
- const demoEmail = `${demoName}-${demoId}@kaneo.app`;
-
- const hashedPassword = await bcrypt.hash("demo", 10);
-
- await db.insert(userTable).values({
- id: demoId,
- name: demoName
- .split("-")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" "),
- email: demoEmail,
- password: hashedPassword,
- });
-
- const token = generateSessionToken();
- const demoSession = await createSession(token, demoId);
-
- return {
- id: demoId,
- name: demoName,
- email: demoEmail,
- session: token,
- expiresAt: demoSession.expiresAt,
- };
-}
diff --git a/apps/api/src/utils/set-demo-user.ts b/apps/api/src/utils/set-demo-user.ts
deleted file mode 100644
index 4587de54a..000000000
--- a/apps/api/src/utils/set-demo-user.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { Context } from "hono";
-import { setCookie } from "hono/cookie";
-import isInSecureMode from "../user/utils/is-in-secure-mode";
-import { createDemoUser } from "./create-demo-user";
-
-async function setDemoUser(c: Context) {
- const demoExpiresAt = new Date(Date.now() + 15 * 60 * 1000);
- const { session: demoSession, expiresAt = demoExpiresAt } =
- await createDemoUser();
-
- setCookie(c, "session", demoSession, {
- httpOnly: isInSecureMode(c.req),
- path: "/",
- secure: true,
- sameSite: "lax",
- expires: expiresAt,
- });
-}
-
-export default setDemoUser;
diff --git a/apps/api/src/workspace-user/controllers/create-root-workspace-user.ts b/apps/api/src/workspace-user/controllers/create-root-workspace-user.ts
index 44956b1b4..b8a24d19b 100644
--- a/apps/api/src/workspace-user/controllers/create-root-workspace-user.ts
+++ b/apps/api/src/workspace-user/controllers/create-root-workspace-user.ts
@@ -1,12 +1,12 @@
import db from "../../database";
import { workspaceUserTable } from "../../database/schema";
-async function createRootWorkspaceUser(workspaceId: string, userEmail: string) {
+async function createRootWorkspaceUser(workspaceId: string, userId: string) {
const [workspaceUser] = await db
.insert(workspaceUserTable)
.values({
workspaceId,
- userEmail,
+ userId,
role: "owner",
status: "active",
})
diff --git a/apps/api/src/workspace-user/controllers/delete-workspace-user.ts b/apps/api/src/workspace-user/controllers/delete-workspace-user.ts
index 4c1d6b3df..d9531ed53 100644
--- a/apps/api/src/workspace-user/controllers/delete-workspace-user.ts
+++ b/apps/api/src/workspace-user/controllers/delete-workspace-user.ts
@@ -2,13 +2,13 @@ import { and, eq } from "drizzle-orm";
import db from "../../database";
import { workspaceUserTable } from "../../database/schema";
-async function deleteWorkspaceUser(workspaceId: string, userEmail: string) {
+async function deleteWorkspaceUser(workspaceId: string, userId: string) {
const [deletedWorkspaceUser] = await db
.delete(workspaceUserTable)
.where(
and(
eq(workspaceUserTable.workspaceId, workspaceId),
- eq(workspaceUserTable.userEmail, userEmail),
+ eq(workspaceUserTable.userId, userId),
),
)
.returning();
diff --git a/apps/api/src/workspace-user/controllers/get-active-workspace-users.ts b/apps/api/src/workspace-user/controllers/get-active-workspace-users.ts
index f61b69c84..ec4fae2e3 100644
--- a/apps/api/src/workspace-user/controllers/get-active-workspace-users.ts
+++ b/apps/api/src/workspace-user/controllers/get-active-workspace-users.ts
@@ -6,7 +6,7 @@ async function getActiveWorkspaceUsers(workspaceId: string) {
const activeWorkspaceUsers = await db
.select({
id: workspaceUserTable.id,
- userEmail: workspaceUserTable.userEmail,
+ userId: workspaceUserTable.userId,
userName: userTable.name,
role: workspaceUserTable.role,
status: workspaceUserTable.status,
@@ -18,7 +18,7 @@ async function getActiveWorkspaceUsers(workspaceId: string) {
eq(workspaceUserTable.status, "active"),
),
)
- .innerJoin(userTable, eq(workspaceUserTable.userEmail, userTable.email));
+ .innerJoin(userTable, eq(workspaceUserTable.userId, userTable.id));
return activeWorkspaceUsers;
}
diff --git a/apps/api/src/workspace-user/controllers/get-workspace-users.ts b/apps/api/src/workspace-user/controllers/get-workspace-users.ts
index 53626008f..bfb0b9bbb 100644
--- a/apps/api/src/workspace-user/controllers/get-workspace-users.ts
+++ b/apps/api/src/workspace-user/controllers/get-workspace-users.ts
@@ -5,14 +5,14 @@ import { userTable, workspaceUserTable } from "../../database/schema";
function getWorkspaceUsers(workspaceId: string) {
return db
.select({
- userEmail: workspaceUserTable.userEmail,
+ userId: workspaceUserTable.userId,
userName: userTable.name,
joinedAt: workspaceUserTable.joinedAt,
status: workspaceUserTable.status,
role: workspaceUserTable.role,
})
.from(workspaceUserTable)
- .leftJoin(userTable, eq(workspaceUserTable.userEmail, userTable.email))
+ .leftJoin(userTable, eq(workspaceUserTable.userId, userTable.id))
.where(eq(workspaceUserTable.workspaceId, workspaceId))
.orderBy(asc(workspaceUserTable.status));
}
diff --git a/apps/api/src/workspace-user/controllers/invite-workspace-user.ts b/apps/api/src/workspace-user/controllers/invite-workspace-user.ts
index abfc76d3d..694a75f63 100644
--- a/apps/api/src/workspace-user/controllers/invite-workspace-user.ts
+++ b/apps/api/src/workspace-user/controllers/invite-workspace-user.ts
@@ -3,7 +3,7 @@ import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { workspaceTable, workspaceUserTable } from "../../database/schema";
-async function inviteWorkspaceUser(workspaceId: string, userEmail: string) {
+async function inviteWorkspaceUser(workspaceId: string, userId: string) {
const [workspace] = await db
.select()
.from(workspaceTable)
@@ -21,7 +21,7 @@ async function inviteWorkspaceUser(workspaceId: string, userEmail: string) {
.where(
and(
eq(workspaceUserTable.workspaceId, workspaceId),
- eq(workspaceUserTable.userEmail, userEmail),
+ eq(workspaceUserTable.userId, userId),
),
);
@@ -34,7 +34,7 @@ async function inviteWorkspaceUser(workspaceId: string, userEmail: string) {
const [invitedUser] = await db
.insert(workspaceUserTable)
.values({
- userEmail,
+ userId,
workspaceId,
})
.returning();
diff --git a/apps/api/src/workspace-user/controllers/update-workspace-user.ts b/apps/api/src/workspace-user/controllers/update-workspace-user.ts
index 9586be18c..4f0c17d86 100644
--- a/apps/api/src/workspace-user/controllers/update-workspace-user.ts
+++ b/apps/api/src/workspace-user/controllers/update-workspace-user.ts
@@ -2,11 +2,11 @@ import { eq } from "drizzle-orm";
import db from "../../database";
import { workspaceUserTable } from "../../database/schema";
-async function updateWorkspaceUser(userEmail: string, status: string) {
+async function updateWorkspaceUser(userId: string, status: string) {
const [updatedWorkspaceUser] = await db
.update(workspaceUserTable)
.set({ status })
- .where(eq(workspaceUserTable.userEmail, userEmail))
+ .where(eq(workspaceUserTable.userId, userId))
.returning();
return updatedWorkspaceUser;
diff --git a/apps/api/src/workspace-user/index.ts b/apps/api/src/workspace-user/index.ts
index 059e35c9d..8b91d60bf 100644
--- a/apps/api/src/workspace-user/index.ts
+++ b/apps/api/src/workspace-user/index.ts
@@ -12,7 +12,7 @@ import updateWorkspaceUser from "./controllers/update-workspace-user";
const workspaceUser = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get("/:id", zValidator("param", z.object({ id: z.string() })), async (c) => {
@@ -28,16 +28,13 @@ const workspaceUser = new Hono<{
"json",
z.object({
workspaceId: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
}),
),
async (c) => {
- const { workspaceId, userEmail } = c.req.valid("json");
+ const { workspaceId, userId } = c.req.valid("json");
- const workspaceUser = await createRootWorkspaceUser(
- workspaceId,
- userEmail,
- );
+ const workspaceUser = await createRootWorkspaceUser(workspaceId, userId);
return c.json(workspaceUser);
},
@@ -56,28 +53,28 @@ const workspaceUser = new Hono<{
.delete(
"/:workspaceId",
zValidator("param", z.object({ workspaceId: z.string() })),
- zValidator("query", z.object({ userEmail: z.string() })),
+ zValidator("query", z.object({ userId: z.string() })),
async (c) => {
const { workspaceId } = c.req.valid("param");
- const { userEmail } = c.req.valid("query");
+ const { userId } = c.req.valid("query");
const deletedWorkspaceUser = await deleteWorkspaceUser(
workspaceId,
- userEmail,
+ userId,
);
return c.json(deletedWorkspaceUser);
},
)
.put(
- "/:userEmail",
- zValidator("param", z.object({ userEmail: z.string() })),
+ "/:userId",
+ zValidator("param", z.object({ userId: z.string() })),
zValidator("json", z.object({ status: z.string() })),
async (c) => {
- const { userEmail } = c.req.valid("param");
+ const { userId } = c.req.valid("param");
const { status } = c.req.valid("json");
- const updatedWorkspaceUser = await updateWorkspaceUser(userEmail, status);
+ const updatedWorkspaceUser = await updateWorkspaceUser(userId, status);
return c.json(updatedWorkspaceUser);
},
@@ -96,28 +93,28 @@ const workspaceUser = new Hono<{
.post(
"/:workspaceId/invite",
zValidator("param", z.object({ workspaceId: z.string() })),
- zValidator("json", z.object({ userEmail: z.string() })),
+ zValidator("json", z.object({ userId: z.string() })),
async (c) => {
const { workspaceId } = c.req.valid("param");
- const { userEmail } = c.req.valid("json");
+ const { userId } = c.req.valid("json");
- const workspaceUser = await inviteWorkspaceUser(workspaceId, userEmail);
+ const workspaceUser = await inviteWorkspaceUser(workspaceId, userId);
return c.json(workspaceUser);
},
)
.delete(
- "/:workspaceId/invite/:userEmail",
+ "/:workspaceId/invite/:userId",
zValidator(
"param",
- z.object({ workspaceId: z.string(), userEmail: z.string() }),
+ z.object({ workspaceId: z.string(), userId: z.string() }),
),
async (c) => {
- const { workspaceId, userEmail } = c.req.valid("param");
+ const { workspaceId, userId } = c.req.valid("param");
const deletedWorkspaceUser = await deleteWorkspaceUser(
workspaceId,
- userEmail,
+ userId,
);
return c.json(deletedWorkspaceUser);
@@ -136,13 +133,13 @@ subscribeToEvent(
"workspace.created",
async ({
workspaceId,
- ownerEmail,
- }: { workspaceId: string; ownerEmail: string }) => {
- if (!workspaceId || !ownerEmail) {
+ ownerId,
+ }: { workspaceId: string; ownerId: string }) => {
+ if (!workspaceId || !ownerId) {
return;
}
- await createRootWorkspaceUser(workspaceId, ownerEmail);
+ await createRootWorkspaceUser(workspaceId, ownerId);
},
);
diff --git a/apps/api/src/workspace/controllers/create-workspace.ts b/apps/api/src/workspace/controllers/create-workspace.ts
index 12d9ba948..1278d6a85 100644
--- a/apps/api/src/workspace/controllers/create-workspace.ts
+++ b/apps/api/src/workspace/controllers/create-workspace.ts
@@ -2,12 +2,12 @@ import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { workspaceTable } from "../../database/schema";
import { publishEvent } from "../../events";
-async function createWorkspace(name: string, ownerEmail: string) {
+async function createWorkspace(name: string, ownerId: string) {
const [workspace] = await db
.insert(workspaceTable)
.values({
name,
- ownerEmail,
+ ownerId,
})
.returning();
@@ -20,7 +20,7 @@ async function createWorkspace(name: string, ownerEmail: string) {
publishEvent("workspace.created", {
workspaceId: workspace.id,
workspaceName: workspace.name,
- ownerEmail,
+ ownerId,
});
return workspace;
diff --git a/apps/api/src/workspace/controllers/delete-workspace.ts b/apps/api/src/workspace/controllers/delete-workspace.ts
index 6982bbc30..a4b2c8cdd 100644
--- a/apps/api/src/workspace/controllers/delete-workspace.ts
+++ b/apps/api/src/workspace/controllers/delete-workspace.ts
@@ -3,17 +3,17 @@ import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { workspaceTable } from "../../database/schema";
-async function deleteWorkspace(userEmail: string, workspaceId: string) {
+async function deleteWorkspace(userId: string, workspaceId: string) {
const [existingWorkspace] = await db
.select({
id: workspaceTable.id,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
})
.from(workspaceTable)
.where(
and(
eq(workspaceTable.id, workspaceId),
- eq(workspaceTable.ownerEmail, userEmail),
+ eq(workspaceTable.ownerId, userId),
),
)
.limit(1);
@@ -32,7 +32,7 @@ async function deleteWorkspace(userEmail: string, workspaceId: string) {
.returning({
id: workspaceTable.id,
name: workspaceTable.name,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
createdAt: workspaceTable.createdAt,
});
diff --git a/apps/api/src/workspace/controllers/get-workspace.ts b/apps/api/src/workspace/controllers/get-workspace.ts
index ee775f9ca..a35dd21c3 100644
--- a/apps/api/src/workspace/controllers/get-workspace.ts
+++ b/apps/api/src/workspace/controllers/get-workspace.ts
@@ -3,12 +3,12 @@ import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { workspaceTable, workspaceUserTable } from "../../database/schema";
-async function getWorkspace(userEmail: string, workspaceId: string) {
+async function getWorkspace(userId: string, workspaceId: string) {
const [existingWorkspace] = await db
.select({
id: workspaceTable.id,
name: workspaceTable.name,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
description: workspaceTable.description,
createdAt: workspaceTable.createdAt,
})
@@ -21,8 +21,8 @@ async function getWorkspace(userEmail: string, workspaceId: string) {
and(
eq(workspaceTable.id, workspaceId),
or(
- eq(workspaceTable.ownerEmail, userEmail),
- eq(workspaceUserTable.userEmail, userEmail),
+ eq(workspaceTable.ownerId, userId),
+ eq(workspaceUserTable.userId, userId),
),
),
)
diff --git a/apps/api/src/workspace/controllers/get-workspaces.ts b/apps/api/src/workspace/controllers/get-workspaces.ts
index 4a14d805e..74a6de536 100644
--- a/apps/api/src/workspace/controllers/get-workspaces.ts
+++ b/apps/api/src/workspace/controllers/get-workspaces.ts
@@ -2,12 +2,12 @@ import { eq, or } from "drizzle-orm";
import db from "../../database";
import { workspaceTable, workspaceUserTable } from "../../database/schema";
-async function getWorkspaces(userEmail: string) {
+async function getWorkspaces(userId: string) {
const workspaces = await db
.select({
id: workspaceTable.id,
name: workspaceTable.name,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
createdAt: workspaceTable.createdAt,
description: workspaceTable.description,
})
@@ -18,14 +18,14 @@ async function getWorkspaces(userEmail: string) {
)
.where(
or(
- eq(workspaceTable.ownerEmail, userEmail),
- eq(workspaceUserTable.userEmail, userEmail),
+ eq(workspaceTable.ownerId, userId),
+ eq(workspaceUserTable.userId, userId),
),
)
.groupBy(
workspaceTable.id,
workspaceTable.name,
- workspaceTable.ownerEmail,
+ workspaceTable.ownerId,
workspaceTable.description,
);
diff --git a/apps/api/src/workspace/controllers/update-workspace.ts b/apps/api/src/workspace/controllers/update-workspace.ts
index e4f383012..d9afa4fa7 100644
--- a/apps/api/src/workspace/controllers/update-workspace.ts
+++ b/apps/api/src/workspace/controllers/update-workspace.ts
@@ -4,7 +4,7 @@ import db from "../../database";
import { workspaceTable } from "../../database/schema";
async function updateWorkspace(
- userEmail: string,
+ userId: string,
workspaceId: string,
name: string,
description: string,
@@ -12,13 +12,13 @@ async function updateWorkspace(
const [existingWorkspace] = await db
.select({
id: workspaceTable.id,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
})
.from(workspaceTable)
.where(
and(
eq(workspaceTable.id, workspaceId),
- eq(workspaceTable.ownerEmail, userEmail),
+ eq(workspaceTable.ownerId, userId),
),
)
.limit(1);
@@ -41,7 +41,7 @@ async function updateWorkspace(
.returning({
id: workspaceTable.id,
name: workspaceTable.name,
- ownerEmail: workspaceTable.ownerEmail,
+ ownerId: workspaceTable.ownerId,
description: workspaceTable.description,
createdAt: workspaceTable.createdAt,
});
diff --git a/apps/api/src/workspace/index.ts b/apps/api/src/workspace/index.ts
index 0c766ac1a..a8f5884e3 100644
--- a/apps/api/src/workspace/index.ts
+++ b/apps/api/src/workspace/index.ts
@@ -9,22 +9,22 @@ import updateWorkspace from "./controllers/update-workspace";
const workspace = new Hono<{
Variables: {
- userEmail: string;
+ userId: string;
};
}>()
.get("/", async (c) => {
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
- const workspaces = await getWorkspaces(userEmail);
+ const workspaces = await getWorkspaces(userId);
return c.json(workspaces);
})
.get("/:id", zValidator("param", z.object({ id: z.string() })), async (c) => {
const id = c.req.param("id");
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
- const workspace = await getWorkspace(userEmail, id);
+ const workspace = await getWorkspace(userId, id);
return c.json(workspace);
})
@@ -34,9 +34,9 @@ const workspace = new Hono<{
async (c) => {
const { name } = c.req.valid("json");
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
- const workspace = await createWorkspace(name, userEmail);
+ const workspace = await createWorkspace(name, userId);
return c.json(workspace);
},
@@ -48,9 +48,9 @@ const workspace = new Hono<{
const id = c.req.param("id");
const { name, description } = c.req.valid("json");
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
- const workspace = await updateWorkspace(userEmail, id, name, description);
+ const workspace = await updateWorkspace(userId, id, name, description);
return c.json(workspace);
},
@@ -61,9 +61,9 @@ const workspace = new Hono<{
async (c) => {
const id = c.req.param("id");
- const userEmail = c.get("userEmail");
+ const userId = c.get("userId");
- const workspace = await deleteWorkspace(userEmail, id);
+ const workspace = await deleteWorkspace(userId, id);
return c.json(workspace);
},
diff --git a/apps/web/package.json b/apps/web/package.json
index 2a791e95c..9bdfb4f60 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -46,6 +46,7 @@
"@types/file-saver": "^2.0.7",
"@vitejs/plugin-react": "^4.7.0",
"babel-plugin-react-compiler": "^19.0.0-beta-714736e-20250131",
+ "better-auth": "^1.3.5",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
diff --git a/apps/web/src/components/auth/layout.tsx b/apps/web/src/components/auth/layout.tsx
index 849796b8c..075e31027 100644
--- a/apps/web/src/components/auth/layout.tsx
+++ b/apps/web/src/components/auth/layout.tsx
@@ -13,17 +13,18 @@ export function AuthLayout({ children, title, subtitle }: AuthLayoutProps) {
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
- className="w-full max-w-md"
+ className="w-full max-w-sm"
>
- <div className="mb-8 text-center">
- <Logo className="mx-auto mb-6" />
- <h1 className="text-3xl font-bold text-zinc-900 dark:text-zinc-100 mb-2">
+ <Logo className="mx-auto mb-6 w-full flex items-end justify-center" />
+
+ <div className="bg-white/50 dark:bg-zinc-900/50 backdrop-blur-xl rounded-xl border border-zinc-200/50 dark:border-zinc-800/50 p-6 shadow-xl shadow-zinc-200/20 dark:shadow-zinc-950/20">
+ <h1 className="text-xl text-center font-bold text-zinc-900 dark:text-zinc-100 mb-2">
{title}
</h1>
- <p className="text-zinc-600 dark:text-zinc-400">{subtitle}</p>
- </div>
+ <p className="text-center text-zinc-600 dark:text-zinc-400 text-sm">
+ {subtitle}
+ </p>
- <div className="bg-white/50 dark:bg-zinc-900/50 backdrop-blur-xl rounded-xl border border-zinc-200/50 dark:border-zinc-800/50 p-6 shadow-xl shadow-zinc-200/20 dark:shadow-zinc-950/20">
{children}
</div>
</motion.div>
diff --git a/apps/web/src/components/auth/sign-in-form.tsx b/apps/web/src/components/auth/sign-in-form.tsx
index 959fcca8f..88cf77f9a 100644
--- a/apps/web/src/components/auth/sign-in-form.tsx
+++ b/apps/web/src/components/auth/sign-in-form.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
-import useSignIn from "@/hooks/mutations/use-sign-in";
+import { authClient } from "@/lib/auth-client";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import { useRouter } from "@tanstack/react-router";
import { Eye, EyeOff } from "lucide-react";
@@ -16,7 +16,6 @@ import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod/v4";
-import useAuth from "../providers/auth-provider/hooks/use-auth";
export type SignInFormValues = {
email: string;
@@ -30,8 +29,8 @@ const signInSchema = z.object({
export function SignInForm() {
const [showPassword, setShowPassword] = useState(false);
+ const [isPending, setIsPending] = useState(false);
const { history } = useRouter();
- const { setUser } = useAuth();
const form = useForm<SignInFormValues>({
resolver: standardSchemaResolver(signInSchema),
defaultValues: {
@@ -39,101 +38,88 @@ export function SignInForm() {
password: "",
},
});
- const { mutateAsync, isPending } = useSignIn();
const onSubmit = async (data: SignInFormValues) => {
+ setIsPending(true);
try {
- const user = await mutateAsync({
+ const result = await authClient.signIn.email({
email: data.email,
password: data.password,
});
- setUser(user);
- toast.success("Signed in successfully");
+ if (result.error) {
+ toast.error(result.error.message || "Failed to sign in");
+ return;
+ }
+
+ toast.success("Signed in successfully");
setTimeout(() => {
history.push("/dashboard");
}, 500);
} catch (error) {
toast.error(error instanceof Error ? error.message : "Failed to sign in");
+ } finally {
+ setIsPending(false);
}
};
return (
<Form {...form}>
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
- <div className="space-y-4">
- <div>
- <FormField
- control={form.control}
- name="email"
- render={({ field }) => (
- <FormItem>
- <FormLabel className="text-sm font-medium text-zinc-300 mb-1.5 block">
- Email
- </FormLabel>
- <FormControl>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-3">
+ <div className="space-y-3">
+ <FormField
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel className="text-sm font-medium">Email</FormLabel>
+ <FormControl>
+ <Input
+ placeholder="[email protected]"
+ type="email"
+ autoComplete="email"
+ {...field}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="password"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel className="text-sm font-medium">Password</FormLabel>
+ <FormControl>
+ <div className="relative">
<Input
- className="bg-white dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700/50 text-zinc-900 dark:text-zinc-100"
- placeholder="[email protected]"
+ placeholder="••••••••"
+ type={showPassword ? "text" : "password"}
+ autoComplete="current-password"
{...field}
/>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
-
- <div>
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel className="text-sm font-medium text-zinc-300 mb-1.5 block">
- Password
- </FormLabel>
- <FormControl>
- <div className="relative">
- <Input
- className="bg-white dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700/50 text-zinc-900 dark:text-zinc-100"
- placeholder="••••••••"
- type={showPassword ? "text" : "password"}
- {...field}
- />
- <button
- type="button"
- onClick={() => setShowPassword(!showPassword)}
- className="absolute right-3 top-1/2 -translate-y-1/2 text-zinc-400 hover:text-zinc-300"
- >
- {showPassword ? (
- <EyeOff size={16} />
- ) : (
- <Eye size={16} />
- )}
- </button>
- </div>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <div className="flex justify-end mt-1">
- <button
- type="button"
- className="text-sm text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300"
- >
- Forgot password?
- </button>
- </div>
- </div>
+ <button
+ type="button"
+ onClick={() => setShowPassword(!showPassword)}
+ className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
+ aria-label={
+ showPassword ? "Hide password" : "Show password"
+ }
+ aria-pressed={showPassword}
+ >
+ {showPassword ? <EyeOff size={16} /> : <Eye size={16} />}
+ </button>
+ </div>
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
</div>
- <Button
- type="submit"
- disabled={isPending}
- className="w-full bg-indigo-600 text-white hover:bg-indigo-500 dark:bg-indigo-500 dark:hover:bg-indigo-400 mt-6"
- >
+ <Button type="submit" disabled={isPending} className="w-full mt-4">
{isPending ? "Signing In..." : "Sign In"}
</Button>
</form>
diff --git a/apps/web/src/components/auth/sign-up-form.tsx b/apps/web/src/components/auth/sign-up-form.tsx
index a8f8a0a17..4cf9281de 100644
--- a/apps/web/src/components/auth/sign-up-form.tsx
+++ b/apps/web/src/components/auth/sign-up-form.tsx
@@ -8,7 +8,7 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
-import useSignUp from "@/hooks/mutations/use-sign-up";
+import { authClient } from "@/lib/auth-client";
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
import { useRouter } from "@tanstack/react-router";
import { Eye, EyeOff } from "lucide-react";
@@ -16,7 +16,6 @@ import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod/v4";
-import useAuth from "../providers/auth-provider/hooks/use-auth";
export type SignUpFormValues = {
email: string;
@@ -32,7 +31,7 @@ const signUpSchema = z.object({
export function SignUpForm() {
const [showPassword, setShowPassword] = useState(false);
- const { setUser } = useAuth();
+ const [isPending, setIsPending] = useState(false);
const { history } = useRouter();
const form = useForm<SignUpFormValues>({
resolver: standardSchemaResolver(signUpSchema),
@@ -42,42 +41,47 @@ export function SignUpForm() {
name: "",
},
});
- const { mutateAsync } = useSignUp();
const onSubmit = async (data: SignUpFormValues) => {
+ setIsPending(true);
try {
- const user = await mutateAsync({
+ const result = await authClient.signUp.email({
email: data.email,
name: data.name,
password: data.password,
});
- setUser(user);
+ if (result.error) {
+ toast.error(result.error.message || "Failed to sign up");
+ return;
+ }
+ toast.success("Account created successfully");
setTimeout(() => {
history.push("/dashboard");
}, 500);
} catch (error) {
toast.error(error instanceof Error ? error.message : "Failed to sign up");
+ } finally {
+ setIsPending(false);
}
};
return (
<Form {...form}>
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
- <div className="space-y-4">
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-3">
+ <div className="space-y-3">
<FormField
control={form.control}
name="name"
render={({ field, fieldState }) => (
<FormItem>
- <FormLabel className="text-sm font-medium text-zinc-300 mb-1.5 block">
- Full Name
- </FormLabel>
+ <FormLabel className="text-sm font-medium">Full Name</FormLabel>
<FormControl>
<Input
- className="bg-white dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700/50 text-zinc-900 dark:text-zinc-100"
- placeholder="Andrej Acevski"
+ placeholder="John Doe"
+ type="text"
+ autoComplete="name"
{...field}
/>
</FormControl>
@@ -91,13 +95,12 @@ export function SignUpForm() {
name="email"
render={({ field, fieldState }) => (
<FormItem>
- <FormLabel className="text-sm font-medium text-zinc-300 mb-1.5 block">
- Email
- </FormLabel>
+ <FormLabel className="text-sm font-medium">Email</FormLabel>
<FormControl>
<Input
- className="bg-white dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700/50 text-zinc-900 dark:text-zinc-100"
- placeholder="[email protected]"
+ placeholder="[email protected]"
+ type="email"
+ autoComplete="email"
{...field}
/>
</FormControl>
@@ -111,21 +114,23 @@ export function SignUpForm() {
name="password"
render={({ field, fieldState }) => (
<FormItem>
- <FormLabel className="text-sm font-medium text-zinc-300 mb-1.5 block">
- Password
- </FormLabel>
+ <FormLabel className="text-sm font-medium">Password</FormLabel>
<FormControl>
<div className="relative">
<Input
- className="bg-white dark:bg-zinc-800/50 border-zinc-200 dark:border-zinc-700/50 text-zinc-900 dark:text-zinc-100"
placeholder="••••••••"
type={showPassword ? "text" : "password"}
+ autoComplete="new-password"
{...field}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
- className="absolute right-3 top-1/2 -translate-y-1/2 text-zinc-400 hover:text-zinc-300"
+ className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
+ aria-label={
+ showPassword ? "Hide password" : "Show password"
+ }
+ aria-pressed={showPassword}
>
{showPassword ? <EyeOff size={16} /> : <Eye size={16} />}
</button>
@@ -137,11 +142,8 @@ export function SignUpForm() {
/>
</div>
- <Button
- type="submit"
- className="w-full bg-indigo-600 text-white hover:bg-indigo-500 dark:bg-indigo-500 dark:hover:bg-indigo-400 mt-6"
- >
- Sign Up
+ <Button type="submit" disabled={isPending} className="w-full mt-4">
+ {isPending ? "Creating Account..." : "Create Account"}
</Button>
</form>
</Form>
diff --git a/apps/web/src/components/auth/toggle.tsx b/apps/web/src/components/auth/toggle.tsx
index 67be2a8b2..f88d5fd3f 100644
--- a/apps/web/src/components/auth/toggle.tsx
+++ b/apps/web/src/components/auth/toggle.tsx
@@ -15,16 +15,14 @@ export function AuthToggle({ message, linkText, linkTo }: AuthToggleProps) {
}
return (
- <div className="mt-6 text-center">
- <p className="text-sm text-zinc-600 dark:text-zinc-400">
- {message}{" "}
- <Link
- to={linkTo}
- className="text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300 font-medium"
- >
- {linkText}
- </Link>
- </p>
+ <div className="text-center text-sm">
+ {message}{" "}
+ <Link
+ to={linkTo}
+ className="underline underline-offset-4 hover:text-primary"
+ >
+ {linkText}
+ </Link>
</div>
);
}
diff --git a/apps/web/src/components/backlog-list-view/backlog-task-row.tsx b/apps/web/src/components/backlog-list-view/backlog-task-row.tsx
index 3665bdf76..99cddb382 100644
--- a/apps/web/src/components/backlog-list-view/backlog-task-row.tsx
+++ b/apps/web/src/components/backlog-list-view/backlog-task-row.tsx
@@ -144,7 +144,7 @@ export default function BacklogTaskRow({ task }: BacklogTaskRowProps) {
<User className="w-3 h-3" />
<span className="truncate max-w-[100px]">
{task.assigneeName ||
- task.userEmail?.split("@")[0] ||
+ task.userId?.split("@")[0] ||
"Unassigned"}
</span>
</div>
diff --git a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
index a9e1f0b15..53406768f 100644
--- a/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
+++ b/apps/web/src/components/kanban-board/task-card-context-menu/task-card-context-menu-content.tsx
@@ -82,8 +82,8 @@ export default function TaskCardContextMenuContent({
const usersOptions = useMemo(() => {
return workspaceUsers?.map((user) => ({
- label: user.userName ?? user.userEmail,
- value: user.userEmail,
+ label: user.userName ?? user.userId,
+ value: user.userId,
}));
}, [workspaceUsers]);
@@ -130,7 +130,7 @@ export default function TaskCardContextMenuContent({
priority: task.priority as "low" | "medium" | "high" | "urgent",
status: task.status,
title: task.title,
- userEmail: task.userEmail ?? "",
+ userId: task.userId ?? "",
projectId,
};
@@ -296,9 +296,9 @@ export default function TaskCardContextMenuContent({
{usersOptions.map((user) => (
<ContextMenuCheckboxItem
key={user.value}
- checked={task.userEmail === user.value}
+ checked={task.userId === user.value}
onCheckedChange={() =>
- handleChange("userEmail", user.value ?? "")
+ handleChange("userId", user.value ?? "")
}
className="flex items-center justify-between cursor-pointer"
>
@@ -306,8 +306,8 @@ export default function TaskCardContextMenuContent({
</ContextMenuCheckboxItem>
))}
<ContextMenuCheckboxItem
- checked={!task.userEmail}
- onCheckedChange={() => handleChange("userEmail", "")}
+ checked={!task.userId}
+ onCheckedChange={() => handleChange("userId", "")}
className="flex items-center justify-between cursor-pointer"
>
Unassigned
diff --git a/apps/web/src/components/kanban-board/task-card.tsx b/apps/web/src/components/kanban-board/task-card.tsx
index 281980523..3c04bd8d3 100644
--- a/apps/web/src/components/kanban-board/task-card.tsx
+++ b/apps/web/src/components/kanban-board/task-card.tsx
@@ -96,7 +96,7 @@ function TaskCard({ task }: TaskCardProps) {
<div className="flex flex-wrap items-center gap-1.5 mt-auto">
{showAssignees &&
- (task.userEmail ? (
+ (task.userId ? (
<div
className="flex items-center gap-1.5 px-2 py-1 rounded-md bg-zinc-100/50 dark:bg-zinc-800/50 group-hover:bg-zinc-100 dark:group-hover:bg-zinc-800/80 transition-colors"
title={task.assigneeName ?? ""}
diff --git a/apps/web/src/components/list-view/task-row.tsx b/apps/web/src/components/list-view/task-row.tsx
index b890531fa..68261cf75 100644
--- a/apps/web/src/components/list-view/task-row.tsx
+++ b/apps/web/src/components/list-view/task-row.tsx
@@ -141,7 +141,7 @@ function TaskRow({ task, projectSlug }: TaskRowProps) {
<User className="w-3 h-3" />
<span className="truncate max-w-[100px]">
{task.assigneeName ||
- task.userEmail?.split("@")[0] ||
+ task.userId?.split("@")[0] ||
"Unassigned"}
</span>
</div>
diff --git a/apps/web/src/components/nav-user.tsx b/apps/web/src/components/nav-user.tsx
index 710b6d674..9aa7d340b 100644
--- a/apps/web/src/components/nav-user.tsx
+++ b/apps/web/src/components/nav-user.tsx
@@ -1,8 +1,6 @@
-"use client";
-
import { ChevronsUpDown, LogOut } from "lucide-react";
-import useAuth from "@/components/providers/auth-provider/hooks/use-auth";
+import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import { SettingsMenu } from "@/components/settings-menu";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
@@ -24,15 +22,13 @@ import useSignOut from "@/hooks/mutations/use-sign-out";
import useProjectStore from "@/store/project";
import useWorkspaceStore from "@/store/workspace";
import { useQueryClient } from "@tanstack/react-query";
-import { useNavigate } from "@tanstack/react-router";
import { toast } from "sonner";
export function NavUser() {
const { isMobile } = useSidebar();
- const { user, setUser } = useAuth();
+ const { user } = useAuth();
const { mutateAsync: signOut, isPending } = useSignOut();
const queryClient = useQueryClient();
- const navigate = useNavigate();
const { setProject } = useProjectStore();
const { setWorkspace } = useWorkspaceStore();
@@ -44,11 +40,9 @@ export function NavUser() {
try {
await signOut();
queryClient.clear();
- setUser(null);
setProject(undefined);
setWorkspace(undefined);
toast.success("Signed out successfully");
- navigate({ to: "/auth/sign-in" });
} catch (error) {
toast.error(
error instanceof Error ? error.message : "Failed to sign out",
@@ -74,7 +68,7 @@ export function NavUser() {
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
>
<Avatar className="h-8 w-8 rounded-lg">
- <AvatarImage src={""} alt={user.name || ""} />
+ <AvatarImage src={user.image ?? ""} alt={user.name || ""} />
<AvatarFallback className="rounded-lg">
{initials}
</AvatarFallback>
@@ -83,7 +77,9 @@ export function NavUser() {
<span className="truncate font-medium">
{user.name || "User"}
</span>
- <span className="truncate text-xs">{user.email}</span>
+ {user.email && (
+ <span className="truncate text-xs">{user.email}</span>
+ )}
</div>
<ChevronsUpDown className="ml-auto size-4" />
</SidebarMenuButton>
@@ -97,7 +93,7 @@ export function NavUser() {
<DropdownMenuLabel className="p-0 font-normal">
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
<Avatar className="h-8 w-8 rounded-lg">
- <AvatarImage src={""} alt={user.name || ""} />
+ <AvatarImage src={user.image ?? ""} alt={user.name || ""} />
<AvatarFallback className="rounded-lg">
{initials}
</AvatarFallback>
@@ -106,7 +102,9 @@ export function NavUser() {
<span className="truncate font-medium">
{user.name || "User"}
</span>
- <span className="truncate text-xs">{user.email}</span>
+ {user.email && (
+ <span className="truncate text-xs">{user.email}</span>
+ )}
</div>
</div>
</DropdownMenuLabel>
diff --git a/apps/web/src/components/project/tasks-import-export.tsx b/apps/web/src/components/project/tasks-import-export.tsx
index f6a434c02..d8bed92f9 100644
--- a/apps/web/src/components/project/tasks-import-export.tsx
+++ b/apps/web/src/components/project/tasks-import-export.tsx
@@ -189,7 +189,7 @@ export function TasksImportExport({ project }: TasksImportExportProps) {
"status": "to-do",
"priority": "low",
"dueDate": "2025-04-20T00:00:00.000Z",
- "userEmail": "[email protected]"
+ "userId": "[email protected]"
}
]
}`}
diff --git a/apps/web/src/components/providers/auth-provider/hooks/use-auth.ts b/apps/web/src/components/providers/auth-provider/hooks/use-auth.ts
index df2525ba4..63748cb82 100644
--- a/apps/web/src/components/providers/auth-provider/hooks/use-auth.ts
+++ b/apps/web/src/components/providers/auth-provider/hooks/use-auth.ts
@@ -1,13 +1,11 @@
import { useContext } from "react";
import { AuthContext } from "..";
-const useAuth = () => {
+export const useAuth = () => {
const context = useContext(AuthContext);
-
if (!context) {
throw new Error("useAuth must be used within an AuthProvider");
}
-
return context;
};
diff --git a/apps/web/src/components/providers/auth-provider/index.tsx b/apps/web/src/components/providers/auth-provider/index.tsx
index 0aa647cc2..28511844f 100644
--- a/apps/web/src/components/providers/auth-provider/index.tsx
+++ b/apps/web/src/components/providers/auth-provider/index.tsx
@@ -1,44 +1,21 @@
-import useGetMe from "@/hooks/queries/use-get-me";
-import type { LoggedInUser } from "@/types/user";
-import {
- type Dispatch,
- type PropsWithChildren,
- type SetStateAction,
- createContext,
- useEffect,
- useMemo,
- useState,
-} from "react";
+import { authClient } from "@/lib/auth-client";
+import type { User } from "@/types/user";
+import { type PropsWithChildren, createContext } from "react";
import { ErrorDisplay } from "../../ui/error-display";
import { LoadingSkeleton } from "../../ui/loading-skeleton";
+const { useSession } = authClient;
+
export const AuthContext = createContext<{
- user: LoggedInUser | null | undefined;
- setUser: Dispatch<SetStateAction<LoggedInUser | null | undefined>>;
+ user: User | null | undefined;
+ isLoading: boolean;
}>({
user: undefined,
- setUser: () => undefined,
+ isLoading: true,
});
function AuthProvider({ children }: PropsWithChildren) {
- const [user, setUser] = useState<LoggedInUser | undefined | null>(undefined);
- const { data, isFetching, error } = useGetMe();
-
- useEffect(() => {
- if (data?.user === null) {
- setUser(null);
- } else if (data?.user) {
- setUser({ ...data?.user });
- }
- }, [data]);
-
- const memoizedValues = useMemo(
- () => ({
- user,
- setUser,
- }),
- [user],
- );
+ const { data, error, isPending } = useSession();
if (error) {
return (
@@ -50,12 +27,12 @@ function AuthProvider({ children }: PropsWithChildren) {
);
}
- if (isFetching || user === undefined) {
+ if (isPending) {
return <LoadingSkeleton />;
}
return (
- <AuthContext.Provider value={memoizedValues}>
+ <AuthContext.Provider value={{ user: data?.user, isLoading: isPending }}>
{children}
</AuthContext.Provider>
);
diff --git a/apps/web/src/components/public-project/task-card.tsx b/apps/web/src/components/public-project/task-card.tsx
index 14a30f633..0ee2b1a50 100644
--- a/apps/web/src/components/public-project/task-card.tsx
+++ b/apps/web/src/components/public-project/task-card.tsx
@@ -59,10 +59,10 @@ export function PublicTaskCard({
</div>
<div className="flex items-center gap-2">
- {task.userEmail && (
+ {task.userId && (
<Avatar className="h-6 w-6 ring-2 ring-zinc-100 dark:ring-zinc-700">
<AvatarFallback className="text-xs font-medium">
- {task.userEmail.charAt(0).toUpperCase()}
+ {task.userId.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
)}
diff --git a/apps/web/src/components/public-project/task-detail-modal.tsx b/apps/web/src/components/public-project/task-detail-modal.tsx
index b3f34848e..83479409f 100644
--- a/apps/web/src/components/public-project/task-detail-modal.tsx
+++ b/apps/web/src/components/public-project/task-detail-modal.tsx
@@ -68,14 +68,14 @@ export function PublicTaskDetailModal({
</div>
)}
- {task.userEmail && (
+ {task.userId && (
<div className="flex items-center gap-2 text-sm text-zinc-600 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-800/50 px-3 py-1.5 rounded-full">
<User className="w-4 h-4" />
<span>Assigned to</span>
<Avatar className="h-5 w-5">
<AvatarFallback className="text-xs font-medium">
{task.assigneeName?.charAt(0).toUpperCase() ??
- task.userEmail?.charAt(0).toUpperCase()}
+ task.userId?.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
<span className="font-medium">{task.assigneeName}</span>
diff --git a/apps/web/src/components/public-project/task-row.tsx b/apps/web/src/components/public-project/task-row.tsx
index 154f2118d..3abd21bb6 100644
--- a/apps/web/src/components/public-project/task-row.tsx
+++ b/apps/web/src/components/public-project/task-row.tsx
@@ -33,10 +33,10 @@ export function PublicTaskRow({
</div>
<div className="flex items-center gap-3">
- {task.userEmail && (
+ {task.userId && (
<Avatar className="h-6 w-6 ring-2 ring-zinc-100 dark:ring-zinc-700">
<AvatarFallback className="text-xs font-medium">
- {task.userEmail.charAt(0).toUpperCase()}
+ {task.userId.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
)}
diff --git a/apps/web/src/components/shared/modals/create-task-modal.tsx b/apps/web/src/components/shared/modals/create-task-modal.tsx
index 40c4a6dff..0728f5dd7 100644
--- a/apps/web/src/components/shared/modals/create-task-modal.tsx
+++ b/apps/web/src/components/shared/modals/create-task-modal.tsx
@@ -92,7 +92,7 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [priority, setPriority] = useState<Priority>("low");
- const [assigneeEmail, setAssigneeEmail] = useState("");
+ const [assigneeId, setAssigneeId] = useState("");
const [dueDate, setDueDate] = useState<Date | undefined>(undefined);
const [createMore, setCreateMore] = useState(false);
const [labels, setLabels] = useState<Label[]>([]);
@@ -110,7 +110,7 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
setTitle("");
setDescription("");
setPriority("low");
- setAssigneeEmail("");
+ setAssigneeId("");
setDueDate(undefined);
setCreateMore(false);
setLabels([]);
@@ -130,7 +130,7 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
const newTask = await mutateAsync({
title: title.trim(),
description: description.trim() || "",
- userEmail: assigneeEmail,
+ userId: assigneeId,
priority,
projectId: project?.id,
dueDate: dueDate ? dueDate.toISOString() : new Date().toISOString(),
@@ -157,8 +157,8 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
if (targetColumn) {
targetColumn.tasks.push({
...newTask,
- assigneeEmail: assigneeEmail,
- assigneeName: assigneeEmail,
+ assigneeId: assigneeId,
+ assigneeName: assigneeId,
position: 0,
});
}
@@ -166,14 +166,14 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
});
setProject(updatedProject);
- updateTask({ ...newTask, position: 0, assigneeEmail: assigneeEmail });
+ updateTask({ ...newTask, position: 0, assigneeId: assigneeId });
toast.success("Task created successfully");
if (createMore) {
setTitle("");
setDescription("");
setPriority("low");
- setAssigneeEmail("");
+ setAssigneeId("");
setDueDate(undefined);
setLabels([]);
setSearchValue("");
@@ -221,7 +221,7 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
];
const selectedPriority = priorityOptions.find((p) => p.value === priority);
- const selectedUser = users?.find((u) => u.userEmail === assigneeEmail);
+ const selectedUser = users?.find((u) => u.userId === assigneeId);
const filteredLabels = labels.filter((label: Label) =>
label.name.toLowerCase().includes(searchValue.toLowerCase()),
@@ -431,17 +431,17 @@ function CreateTaskModal({ open, onClose, status }: CreateTaskModalProps) {
<button
type="button"
className="w-full flex items-center gap-3 px-3 py-2 text-sm rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800/50 text-zinc-900 dark:text-zinc-300 transition-all duration-200 hover:scale-[1.02]"
- onClick={() => setAssigneeEmail("")}
+ onClick={() => setAssigneeId("")}
>
<UserIcon className="w-4 h-4 text-zinc-600 dark:text-zinc-500" />
Unassigned
</button>
{users?.map((user) => (
<button
- key={user.userEmail}
+ key={user.userId}
type="button"
className="w-full flex items-center gap-3 px-3 py-2 text-sm rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800/50 text-zinc-900 dark:text-zinc-300 transition-all duration-200 hover:scale-[1.02]"
- onClick={() => setAssigneeEmail(user.userEmail || "")}
+ onClick={() => setAssigneeId(user.userId || "")}
>
<div className="w-4 h-4 bg-zinc-400 dark:bg-zinc-600 rounded-full flex items-center justify-center text-[10px] text-white font-bold">
{user.userName?.charAt(0).toUpperCase() || "?"}
diff --git a/apps/web/src/components/task/task-activities.tsx b/apps/web/src/components/task/task-activities.tsx
index f50b52c78..b2fc8e4b7 100644
--- a/apps/web/src/components/task/task-activities.tsx
+++ b/apps/web/src/components/task/task-activities.tsx
@@ -7,7 +7,7 @@ import { Route } from "@/routes/dashboard/workspace/$workspaceId/project/$projec
import { formatDistanceToNow } from "date-fns";
import { History, MessageSquare, Pencil, PlusCircle } from "lucide-react";
import { useState } from "react";
-import useAuth from "../providers/auth-provider/hooks/use-auth";
+import { useAuth } from "../providers/auth-provider/hooks/use-auth";
import TaskComment from "./task-comment";
function TaskActivities() {
@@ -18,10 +18,10 @@ function TaskActivities() {
const [editingCommentId, setEditingCommentId] = useState<string | null>(null);
const handleDeleteComment = (activityId: string) => {
- if (user?.email) {
+ if (user?.id) {
deleteComment({
id: activityId,
- userEmail: user.email,
+ userId: user.id,
});
}
};
@@ -32,7 +32,9 @@ function TaskActivities() {
<div key={activity.id} className="flex items-start gap-4">
<div className="relative">
<Avatar className="w-8 h-8">
- <AvatarFallback>{activity.userEmail.charAt(0)}</AvatarFallback>
+ <AvatarFallback>
+ {activity.userId?.charAt(0) || "U"}
+ </AvatarFallback>
</Avatar>
<div
className={cn(
@@ -58,7 +60,7 @@ function TaskActivities() {
<div className="flex-1 flex flex-col gap-2">
<div className="flex items-center gap-2">
<span className="text-sm font-medium text-zinc-900 dark:text-zinc-400">
- {activity.userEmail}
+ {activity.userId}
</span>
<span className="text-xs text-zinc-500 dark:text-zinc-400">
{formatDistanceToNow(activity.createdAt)} ago
diff --git a/apps/web/src/components/task/task-comment.tsx b/apps/web/src/components/task/task-comment.tsx
index 93254b93c..d90595df3 100644
--- a/apps/web/src/components/task/task-comment.tsx
+++ b/apps/web/src/components/task/task-comment.tsx
@@ -1,5 +1,5 @@
import { Editor } from "@/components/common/editor";
-import useAuth from "@/components/providers/auth-provider/hooks/use-auth";
+import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import { Button } from "@/components/ui/button";
import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
import useCreateComment from "@/hooks/mutations/comment/use-create-comment";
@@ -41,7 +41,7 @@ function TaskComment({
});
async function handleSubmit(data: z.infer<typeof commentSchema>) {
- if (!user?.email) {
+ if (!user?.id) {
return;
}
@@ -49,7 +49,7 @@ function TaskComment({
if (commentId) {
await updateComment({
id: commentId,
- userEmail: user.email,
+ userId: user.id,
content: data.comment,
});
onSubmit?.();
@@ -57,7 +57,7 @@ function TaskComment({
await createComment({
taskId: taskId,
content: data.comment,
- userEmail: user?.email,
+ userId: user?.id,
});
onSubmit?.();
}
diff --git a/apps/web/src/components/task/task-description.tsx b/apps/web/src/components/task/task-description.tsx
index b808fbee4..3fad36c44 100644
--- a/apps/web/src/components/task/task-description.tsx
+++ b/apps/web/src/components/task/task-description.tsx
@@ -32,7 +32,7 @@ function TaskDescription({ setIsSaving }: TaskDescriptionProps) {
await updateTask({
...task,
description: value,
- userEmail: task.userEmail || "",
+ userId: task.userId || "",
title: task.title || "",
status: task.status || "",
dueDate: task.dueDate ? new Date(task.dueDate).toISOString() : null,
diff --git a/apps/web/src/components/task/task-info.tsx b/apps/web/src/components/task/task-info.tsx
index 0ac93e14a..40208a376 100644
--- a/apps/web/src/components/task/task-info.tsx
+++ b/apps/web/src/components/task/task-info.tsx
@@ -33,7 +33,7 @@ import TaskLabels from "./task-labels";
export const taskInfoSchema = z.object({
status: z.string(),
- userEmail: z.string(),
+ userId: z.string(),
priority: z.string(),
dueDate: z.date(),
});
@@ -58,7 +58,7 @@ function TaskInfo({
const form = useForm<z.infer<typeof taskInfoSchema>>({
defaultValues: {
status: task?.status || "",
- userEmail: task?.userEmail || "",
+ userId: task?.userId || "",
priority: task?.priority || "",
dueDate: task?.dueDate ? new Date(task.dueDate) : new Date(),
},
@@ -71,7 +71,7 @@ function TaskInfo({
try {
await updateTask({
...task,
- userEmail: data.userEmail,
+ userId: data.userId,
status: data.status || "",
priority: data.priority || "",
dueDate: data.dueDate.toISOString(),
@@ -150,7 +150,7 @@ function TaskInfo({
<FormField
control={form.control}
- name="userEmail"
+ name="userId"
render={({ field }) => (
<FormItem>
<FormLabel>Assign to</FormLabel>
@@ -158,7 +158,7 @@ function TaskInfo({
value={field.value}
onValueChange={(value) => {
field.onChange(value);
- handleChange({ ...form.getValues(), userEmail: value });
+ handleChange({ ...form.getValues(), userId: value });
}}
>
<SelectTrigger>
@@ -168,7 +168,7 @@ function TaskInfo({
<SelectItem value="unassigned">Unassigned</SelectItem>
{workspaceUsers?.map((user) => {
return (
- <SelectItem key={user.userEmail} value={user.userEmail}>
+ <SelectItem key={user.userId} value={user.userId}>
{user.userName}
</SelectItem>
);
diff --git a/apps/web/src/components/task/task-title.tsx b/apps/web/src/components/task/task-title.tsx
index 545f3ff3e..0fadaf9bd 100644
--- a/apps/web/src/components/task/task-title.tsx
+++ b/apps/web/src/components/task/task-title.tsx
@@ -31,7 +31,7 @@ function TaskTitle({
await updateTask({
...task,
title: value,
- userEmail: task.userEmail || "",
+ userId: task.userId || "",
status: task.status || "",
dueDate: task.dueDate ? new Date(task.dueDate).toISOString() : null,
priority: task.priority || "",
diff --git a/apps/web/src/components/team/delete-team-member-modal.tsx b/apps/web/src/components/team/delete-team-member-modal.tsx
index 2dcaff141..aac77a648 100644
--- a/apps/web/src/components/team/delete-team-member-modal.tsx
+++ b/apps/web/src/components/team/delete-team-member-modal.tsx
@@ -6,11 +6,11 @@ import { Trash2, X } from "lucide-react";
import { Button } from "../ui/button";
function DeleteTeamMemberModal({
- userEmail,
+ userId,
open,
onClose,
}: {
- userEmail: string;
+ userId: string;
open: boolean;
onClose: () => void;
}) {
@@ -21,7 +21,7 @@ function DeleteTeamMemberModal({
const onRemoveMember = async () => {
await deleteWorkspaceUser({
workspaceId,
- userEmail,
+ userId,
});
queryClient.invalidateQueries({
@@ -50,7 +50,7 @@ function DeleteTeamMemberModal({
<p className="text-sm text-zinc-600 dark:text-zinc-400 mb-6">
Are you sure you want to remove{" "}
<span className="font-medium text-zinc-900 dark:text-zinc-100">
- {userEmail}
+ {userId}
</span>{" "}
from the team? This action cannot be undone.
</p>
diff --git a/apps/web/src/components/team/invite-team-member-modal.tsx b/apps/web/src/components/team/invite-team-member-modal.tsx
index 37c097c7d..51282fc24 100644
--- a/apps/web/src/components/team/invite-team-member-modal.tsx
+++ b/apps/web/src/components/team/invite-team-member-modal.tsx
@@ -24,7 +24,7 @@ type Props = {
};
const teamMemberSchema = z.object({
- userEmail: z.email(),
+ userId: z.string(),
});
type TeamMemberFormValues = z.infer<typeof teamMemberSchema>;
@@ -37,13 +37,13 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
const form = useForm<TeamMemberFormValues>({
resolver: standardSchemaResolver(teamMemberSchema),
defaultValues: {
- userEmail: "",
+ userId: "",
},
});
- const onSubmit = async ({ userEmail }: TeamMemberFormValues) => {
+ const onSubmit = async ({ userId }: TeamMemberFormValues) => {
try {
- await mutateAsync({ userEmail, workspaceId });
+ await mutateAsync({ userId, workspaceId });
await queryClient.refetchQueries({
queryKey: ["workspace-users", workspaceId],
});
@@ -95,7 +95,7 @@ function InviteTeamMemberModal({ open, onClose }: Props) {
<div>
<FormField
control={form.control}
- name="userEmail"
+ name="userId"
render={({ field }) => (
<FormItem>
<FormLabel className="block text-sm font-medium text-zinc-900 dark:text-zinc-300 mb-1">
diff --git a/apps/web/src/components/team/members-table.tsx b/apps/web/src/components/team/members-table.tsx
index 0fbaa1ed7..c77e88f48 100644
--- a/apps/web/src/components/team/members-table.tsx
+++ b/apps/web/src/components/team/members-table.tsx
@@ -69,15 +69,15 @@ function MembersTable({ users }: { users: WorkspaceUser[] }) {
</TableHeader>
<TableBody>
{users?.map((member) => (
- <TableRow key={member.userEmail} className="cursor-pointer">
+ <TableRow key={member.userId} className="cursor-pointer">
<TableCell className="py-3">
<div className="flex items-center gap-3">
<Avatar className="h-5 w-5">
<AvatarFallback className="bg-muted text-muted-foreground font-medium text-xs">
- {member.userEmail?.charAt(0).toUpperCase()}
+ {member.userId?.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
- <span className="font-medium">{member.userEmail}</span>
+ <span className="font-medium">{member.userId}</span>
</div>
</TableCell>
<TableCell className="py-3">
@@ -143,7 +143,7 @@ function MembersTable({ users }: { users: WorkspaceUser[] }) {
{selectedMember && (
<DeleteTeamMemberModal
- userEmail={selectedMember.userEmail ?? ""}
+ userId={selectedMember.userId ?? ""}
open={isRemoveMemberModalOpen}
onClose={() => {
setIsRemoveMemberModalOpen(false);
diff --git a/apps/web/src/fetchers/activity/create-activity.ts b/apps/web/src/fetchers/activity/create-activity.ts
index 9988f7e80..a8d3f39cc 100644
--- a/apps/web/src/fetchers/activity/create-activity.ts
+++ b/apps/web/src/fetchers/activity/create-activity.ts
@@ -8,13 +8,13 @@ export type CreateActivityRequest = InferRequestType<
async function createActivity({
taskId,
content,
- userEmail,
+ userId,
}: CreateActivityRequest) {
const response = await client.activity.comment.$post({
json: {
taskId,
content,
- userEmail,
+ userId,
},
});
diff --git a/apps/web/src/fetchers/comment/create-comment.ts b/apps/web/src/fetchers/comment/create-comment.ts
index b57d2ff9a..dc6d7e4c6 100644
--- a/apps/web/src/fetchers/comment/create-comment.ts
+++ b/apps/web/src/fetchers/comment/create-comment.ts
@@ -8,13 +8,13 @@ export type CreateCommentRequest = InferRequestType<
async function createComment({
taskId,
content,
- userEmail,
+ userId,
}: CreateCommentRequest) {
const response = await client.activity.comment.$post({
json: {
taskId,
content,
- userEmail,
+ userId,
},
});
diff --git a/apps/web/src/fetchers/comment/delete-comment.ts b/apps/web/src/fetchers/comment/delete-comment.ts
index 3607c50b7..c6aca8a9f 100644
--- a/apps/web/src/fetchers/comment/delete-comment.ts
+++ b/apps/web/src/fetchers/comment/delete-comment.ts
@@ -5,9 +5,9 @@ export type DeleteCommentRequest = InferRequestType<
(typeof client)["activity"]["comment"]["$delete"]
>["json"];
-async function deleteComment({ id, userEmail }: DeleteCommentRequest) {
+async function deleteComment({ id, userId }: DeleteCommentRequest) {
const response = await client.activity.comment.$delete({
- json: { id, userEmail },
+ json: { id, userId },
});
if (!response.ok) {
diff --git a/apps/web/src/fetchers/comment/update-comment.ts b/apps/web/src/fetchers/comment/update-comment.ts
index b6414f789..ac9a09fa4 100644
--- a/apps/web/src/fetchers/comment/update-comment.ts
+++ b/apps/web/src/fetchers/comment/update-comment.ts
@@ -5,12 +5,12 @@ export type UpdateCommentRequest = InferRequestType<
(typeof client)["activity"]["comment"]["$put"]
>["json"];
-async function updateComment({ id, content, userEmail }: UpdateCommentRequest) {
+async function updateComment({ id, content, userId }: UpdateCommentRequest) {
const response = await client.activity.comment.$put({
json: {
id,
content,
- userEmail,
+ userId,
},
});
diff --git a/apps/web/src/fetchers/task/create-task.ts b/apps/web/src/fetchers/task/create-task.ts
index 9e7155f7b..44622b14d 100644
--- a/apps/web/src/fetchers/task/create-task.ts
+++ b/apps/web/src/fetchers/task/create-task.ts
@@ -10,7 +10,7 @@ async function createTask(
title: string,
description: string,
projectId: string,
- userEmail: string,
+ userId: string,
status: string,
dueDate: Date,
priority: string,
@@ -19,7 +19,7 @@ async function createTask(
json: {
title,
description,
- userEmail,
+ userId,
status,
dueDate: dueDate.toISOString(),
priority,
diff --git a/apps/web/src/fetchers/task/import-tasks.ts b/apps/web/src/fetchers/task/import-tasks.ts
index 71aa708e4..3fd9966f4 100644
--- a/apps/web/src/fetchers/task/import-tasks.ts
+++ b/apps/web/src/fetchers/task/import-tasks.ts
@@ -6,7 +6,7 @@ export type TaskToImport = {
status: string;
priority?: string;
dueDate?: string;
- userEmail?: string | null;
+ userId?: string | null;
};
async function importTasks(projectId: string, tasks: TaskToImport[]) {
diff --git a/apps/web/src/fetchers/task/update-task.ts b/apps/web/src/fetchers/task/update-task.ts
index ef063ff1f..4dedb6b16 100644
--- a/apps/web/src/fetchers/task/update-task.ts
+++ b/apps/web/src/fetchers/task/update-task.ts
@@ -5,7 +5,7 @@ async function updateTask(taskId: string, task: Task) {
const response = await client.task[":id"].$put({
param: { id: taskId },
json: {
- userEmail: task.userEmail || "",
+ userId: task.userId || "",
title: task.title,
description: task.description || "",
status: task.status,
diff --git a/apps/web/src/fetchers/user/me.ts b/apps/web/src/fetchers/user/me.ts
deleted file mode 100644
index 400c7235f..000000000
--- a/apps/web/src/fetchers/user/me.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { client } from "@kaneo/libs";
-
-const me = async () => {
- const response = await client.me.$get();
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(error);
- }
-
- const data = await response.json();
-
- return data;
-};
-
-export default me;
diff --git a/apps/web/src/fetchers/user/sign-in.ts b/apps/web/src/fetchers/user/sign-in.ts
deleted file mode 100644
index fd99b2e52..000000000
--- a/apps/web/src/fetchers/user/sign-in.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { SignInFormValues } from "@/components/auth/sign-in-form";
-import { client } from "@kaneo/libs";
-
-const signIn = async ({ email, password }: SignInFormValues) => {
- const response = await client.user["sign-in"].$post({
- json: {
- email,
- password,
- },
- });
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(error);
- }
-
- const user = await response.json();
-
- return user;
-};
-
-export default signIn;
diff --git a/apps/web/src/fetchers/user/sign-out.ts b/apps/web/src/fetchers/user/sign-out.ts
deleted file mode 100644
index 149f1af78..000000000
--- a/apps/web/src/fetchers/user/sign-out.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { client } from "@kaneo/libs";
-
-const signOut = async () => {
- const response = await client.user["sign-out"].$post();
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(error);
- }
-};
-
-export default signOut;
diff --git a/apps/web/src/fetchers/user/sign-up.ts b/apps/web/src/fetchers/user/sign-up.ts
deleted file mode 100644
index 27f55d039..000000000
--- a/apps/web/src/fetchers/user/sign-up.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { SignUpFormValues } from "@/components/auth/sign-up-form";
-import { client } from "@kaneo/libs";
-
-const signUp = async ({ email, password, name }: SignUpFormValues) => {
- const response = await client.user["sign-up"].$post({
- json: {
- email,
- password,
- name,
- },
- });
-
- if (!response.ok) {
- const error = await response.text();
- throw new Error(error);
- }
-
- const user = await response.json();
-
- return user;
-};
-
-export default signUp;
diff --git a/apps/web/src/fetchers/workspace-user/delete-workspace-user.ts b/apps/web/src/fetchers/workspace-user/delete-workspace-user.ts
index 2698d2d54..7bb126a4b 100644
--- a/apps/web/src/fetchers/workspace-user/delete-workspace-user.ts
+++ b/apps/web/src/fetchers/workspace-user/delete-workspace-user.ts
@@ -10,11 +10,11 @@ export type DeleteWorkspaceUserRequest = InferRequestType<
async function deleteWorkspaceUser({
workspaceId,
- userEmail,
+ userId,
}: DeleteWorkspaceUserRequest) {
const response = await client["workspace-user"][":workspaceId"].$delete({
param: { workspaceId },
- query: { userEmail },
+ query: { userId },
});
if (!response.ok) {
diff --git a/apps/web/src/fetchers/workspace-user/invite-workspace-member.ts b/apps/web/src/fetchers/workspace-user/invite-workspace-member.ts
index f00676e13..d3bad78c3 100644
--- a/apps/web/src/fetchers/workspace-user/invite-workspace-member.ts
+++ b/apps/web/src/fetchers/workspace-user/invite-workspace-member.ts
@@ -10,10 +10,10 @@ export type InviteWorkspaceMemberRequest = InferRequestType<
const inviteWorkspaceMember = async ({
workspaceId,
- userEmail,
+ userId,
}: InviteWorkspaceMemberRequest) => {
const response = await client["workspace-user"][":workspaceId"].invite.$post({
- json: { userEmail },
+ json: { userId },
param: { workspaceId },
});
diff --git a/apps/web/src/hooks/mutations/task/use-create-task.ts b/apps/web/src/hooks/mutations/task/use-create-task.ts
index 3286860d2..ffa0b0a33 100644
--- a/apps/web/src/hooks/mutations/task/use-create-task.ts
+++ b/apps/web/src/hooks/mutations/task/use-create-task.ts
@@ -8,7 +8,7 @@ function useCreateTask() {
mutationFn: ({
title,
description,
- userEmail,
+ userId,
projectId,
status,
dueDate,
@@ -18,7 +18,7 @@ function useCreateTask() {
title,
description,
projectId,
- userEmail ?? "",
+ userId ?? "",
status,
new Date(dueDate),
priority,
diff --git a/apps/web/src/hooks/mutations/use-sign-in.ts b/apps/web/src/hooks/mutations/use-sign-in.ts
index e4fab4a1c..c455985b4 100644
--- a/apps/web/src/hooks/mutations/use-sign-in.ts
+++ b/apps/web/src/hooks/mutations/use-sign-in.ts
@@ -1,9 +1,18 @@
-import signIn from "@/fetchers/user/sign-in";
+import { authClient } from "@/lib/auth-client";
import { useMutation } from "@tanstack/react-query";
function useSignIn() {
return useMutation({
- mutationFn: signIn,
+ mutationFn: async ({
+ email,
+ password,
+ }: { email: string; password: string }) => {
+ const result = await authClient.signIn.email({ email, password });
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ return result.data;
+ },
});
}
diff --git a/apps/web/src/hooks/mutations/use-sign-out.ts b/apps/web/src/hooks/mutations/use-sign-out.ts
index bc68159d3..8c3b19a0b 100644
--- a/apps/web/src/hooks/mutations/use-sign-out.ts
+++ b/apps/web/src/hooks/mutations/use-sign-out.ts
@@ -1,9 +1,24 @@
-import signOut from "@/fetchers/user/sign-out";
+import { authClient } from "@/lib/auth-client";
import { useMutation } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
function useSignOut() {
+ const navigate = useNavigate();
+
return useMutation({
- mutationFn: signOut,
+ mutationFn: async () => {
+ const result = await authClient.signOut({
+ fetchOptions: {
+ onSuccess: () => {
+ navigate({ to: "/auth/sign-in" });
+ },
+ },
+ });
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ return result.data;
+ },
});
}
diff --git a/apps/web/src/hooks/mutations/use-sign-up.ts b/apps/web/src/hooks/mutations/use-sign-up.ts
index e23c684b9..fbb19fb55 100644
--- a/apps/web/src/hooks/mutations/use-sign-up.ts
+++ b/apps/web/src/hooks/mutations/use-sign-up.ts
@@ -1,9 +1,19 @@
-import signUp from "@/fetchers/user/sign-up";
+import { authClient } from "@/lib/auth-client";
import { useMutation } from "@tanstack/react-query";
function useSignUp() {
return useMutation({
- mutationFn: signUp,
+ mutationFn: async ({
+ email,
+ password,
+ name,
+ }: { email: string; password: string; name: string }) => {
+ const result = await authClient.signUp.email({ email, password, name });
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ return result.data;
+ },
});
}
diff --git a/apps/web/src/hooks/mutations/workspace-user/use-delete-workspace-user.ts b/apps/web/src/hooks/mutations/workspace-user/use-delete-workspace-user.ts
index 2750ba410..8c701d7aa 100644
--- a/apps/web/src/hooks/mutations/workspace-user/use-delete-workspace-user.ts
+++ b/apps/web/src/hooks/mutations/workspace-user/use-delete-workspace-user.ts
@@ -6,8 +6,8 @@ import deleteWorkspaceUser, {
function useDeleteWorkspaceUser() {
return useMutation({
- mutationFn: ({ workspaceId, userEmail }: DeleteWorkspaceUserRequest) =>
- deleteWorkspaceUser({ workspaceId, userEmail }),
+ mutationFn: ({ workspaceId, userId }: DeleteWorkspaceUserRequest) =>
+ deleteWorkspaceUser({ workspaceId, userId }),
});
}
diff --git a/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts b/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
index 03bf221c8..44c340633 100644
--- a/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
+++ b/apps/web/src/hooks/mutations/workspace-user/use-invite-workspace-user.ts
@@ -5,9 +5,9 @@ function useInviteWorkspaceUser() {
return useMutation({
mutationFn: ({
workspaceId,
- userEmail,
- }: { workspaceId: string; userEmail: string }) =>
- inviteWorkspaceMember({ workspaceId, userEmail }),
+ userId,
+ }: { workspaceId: string; userId: string }) =>
+ inviteWorkspaceMember({ workspaceId, userId }),
});
}
diff --git a/apps/web/src/hooks/queries/use-get-me.ts b/apps/web/src/hooks/queries/use-get-me.ts
deleted file mode 100644
index 15d2ccfd1..000000000
--- a/apps/web/src/hooks/queries/use-get-me.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import me from "@/fetchers/user/me";
-import { useQuery } from "@tanstack/react-query";
-
-function useGetMe() {
- return useQuery({
- queryKey: ["me"],
- queryFn: () => me(),
- retry: 0,
- refetchOnMount: false,
- refetchOnWindowFocus: false,
- });
-}
-
-export default useGetMe;
diff --git a/apps/web/src/hooks/queries/workspace/use-get-workspaces.ts b/apps/web/src/hooks/queries/workspace/use-get-workspaces.ts
index de81e1499..1b0be99f8 100644
--- a/apps/web/src/hooks/queries/workspace/use-get-workspaces.ts
+++ b/apps/web/src/hooks/queries/workspace/use-get-workspaces.ts
@@ -1,4 +1,4 @@
-import useAuth from "@/components/providers/auth-provider/hooks/use-auth";
+import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import getWorkspaces from "@/fetchers/workspace/get-workspaces";
import { useQuery } from "@tanstack/react-query";
@@ -7,8 +7,8 @@ function useGetWorkspaces() {
return useQuery({
queryFn: () => getWorkspaces(),
- queryKey: ["workspaces", user?.email],
- enabled: !!user?.email,
+ queryKey: ["workspaces", user?.id],
+ enabled: !!user?.id,
});
}
diff --git a/apps/web/src/hooks/use-task-filters.ts b/apps/web/src/hooks/use-task-filters.ts
index d7637ef37..462de2d28 100644
--- a/apps/web/src/hooks/use-task-filters.ts
+++ b/apps/web/src/hooks/use-task-filters.ts
@@ -28,7 +28,7 @@ export function useTaskFilters(project: ProjectWithTasks | null | undefined) {
return false;
}
- if (filters.assignee && task.userEmail !== filters.assignee) {
+ if (filters.assignee && task.userId !== filters.assignee) {
return false;
}
diff --git a/apps/web/src/hooks/useWorkspacePermission.ts b/apps/web/src/hooks/useWorkspacePermission.ts
index 6055d2504..18189bf24 100644
--- a/apps/web/src/hooks/useWorkspacePermission.ts
+++ b/apps/web/src/hooks/useWorkspacePermission.ts
@@ -1,4 +1,4 @@
-import useAuth from "@/components/providers/auth-provider/hooks/use-auth";
+import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import useWorkspaceStore from "@/store/workspace";
export type PermissionLevel = "owner" | "member";
@@ -7,7 +7,7 @@ export function useWorkspacePermission() {
const { workspace } = useWorkspaceStore();
const { user } = useAuth();
- const isOwner = workspace?.ownerEmail === user?.email;
+ const isOwner = workspace?.ownerId === user?.id;
const checkPermission = (
requiredRole: PermissionLevel = "member",
diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.ts
new file mode 100644
index 000000000..8e5d3acb9
--- /dev/null
+++ b/apps/web/src/lib/auth-client.ts
@@ -0,0 +1,7 @@
+import { anonymousClient } from "better-auth/client/plugins";
+import { createAuthClient } from "better-auth/react";
+
+export const authClient = createAuthClient({
+ baseURL: import.meta.env.VITE_API_URL || "http://localhost:1337",
+ plugins: [anonymousClient()],
+});
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index d323cccd5..99548f1d0 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -4,8 +4,8 @@ import { RouterProvider, createRouter } from "@tanstack/react-router";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "@/index.css";
+import { useAuth } from "@/components/providers/auth-provider/hooks/use-auth";
import AuthProvider from "./components/providers/auth-provider";
-import useAuth from "./components/providers/auth-provider/hooks/use-auth";
import { ThemeProvider } from "./components/providers/theme-provider";
import { ErrorBoundary } from "./components/ui/error-boundary";
import { ErrorFallback } from "./components/ui/error-fallback";
diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx
index 3c83270fb..a8472d1e7 100644
--- a/apps/web/src/routes/__root.tsx
+++ b/apps/web/src/routes/__root.tsx
@@ -1,7 +1,7 @@
import CommandPalette from "@/components/command-palette";
import SearchCommandMenu from "@/components/search-command-menu";
import { useUserPreferencesStore } from "@/store/user-preferences";
-import type { LoggedInUser } from "@/types/user";
+import type { User } from "@/types/user";
import type { QueryClient } from "@tanstack/react-query";
import {
Outlet,
@@ -14,7 +14,7 @@ import { Toaster } from "sonner";
export const Route = createRootRouteWithContext<{
queryClient: QueryClient;
- user: LoggedInUser | null | undefined;
+ user: User | null | undefined;
}>()({
component: RootComponent,
async beforeLoad({ context: { user }, location }) {
@@ -23,7 +23,7 @@ export const Route = createRootRouteWithContext<{
location.pathname.includes("public-project");
const isOnDashboard = location.pathname.includes("dashboard");
- if (user === null && !isRouteUnprotected) {
+ if (user === undefined && !isRouteUnprotected) {
throw redirect({
to: "/auth/sign-in",
});
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index ac4a3fbb0..ab0b5db1a 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -1,5 +1,10 @@
import PageTitle from "@/components/page-title";
-import { createFileRoute } from "@tanstack/react-router";
+import { Button } from "@/components/ui/button";
+import { authClient } from "@/lib/auth-client";
+import { createFileRoute, useNavigate } from "@tanstack/react-router";
+import { Github, UserCheck } from "lucide-react";
+import { useState } from "react";
+import { toast } from "sonner";
import { AuthLayout } from "../../components/auth/layout";
import { SignInForm } from "../../components/auth/sign-in-form";
import { AuthToggle } from "../../components/auth/toggle";
@@ -9,6 +14,53 @@ export const Route = createFileRoute("/auth/sign-in")({
});
function SignIn() {
+ const navigate = useNavigate();
+ const [isGuestLoading, setIsGuestLoading] = useState(false);
+ const [isGithubLoading, setIsGithubLoading] = useState(false);
+
+ const handleGuestAccess = async () => {
+ setIsGuestLoading(true);
+ try {
+ const result = await authClient.signIn.anonymous();
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ toast.success("Signed in as guest");
+ navigate({ to: "/dashboard" });
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to sign in as guest",
+ );
+ } finally {
+ setIsGuestLoading(false);
+ }
+ };
+
+ const handleSignInGithub = async () => {
+ setIsGithubLoading(true);
+ try {
+ const result = await authClient.signIn.social({
+ provider: "github",
+ callbackURL: `${window.location.origin}/api/auth/callback/github`,
+ errorCallbackURL: `${window.location.origin}/auth/sign-in`,
+ });
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ toast.success("Signed in with Github");
+ navigate({ to: "/dashboard" });
+ setIsGithubLoading(false);
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to sign in with Github",
+ );
+ } finally {
+ setIsGithubLoading(false);
+ }
+ };
+
return (
<>
<PageTitle title="Sign In" />
@@ -16,12 +68,40 @@ function SignIn() {
title="Welcome back"
subtitle="Enter your credentials to access your workspace"
>
- <SignInForm />
- <AuthToggle
- message="Don't have an account?"
- linkText="Create account"
- linkTo="/auth/sign-up"
- />
+ <div className="space-y-4 mt-6">
+ <div className="flex flex-col gap-2">
+ <Button
+ variant="outline"
+ onClick={handleSignInGithub}
+ disabled={isGithubLoading}
+ className="w-full"
+ >
+ <Github className="w-4 h-4 mr-2" />
+ {isGithubLoading ? "Signing in..." : "Continue with GitHub"}
+ </Button>
+ <Button
+ variant="outline"
+ onClick={handleGuestAccess}
+ disabled={isGuestLoading}
+ className="w-full"
+ size="sm"
+ >
+ <UserCheck className="w-4 h-4 mr-2" />
+ {isGuestLoading ? "Signing in..." : "Continue as guest"}
+ </Button>
+ </div>
+ <div className="flex items-center gap-4 my-4">
+ <div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-800" />
+ <span className="text-sm text-zinc-500 dark:text-zinc-400">or</span>
+ <div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-800" />
+ </div>
+ <SignInForm />
+ <AuthToggle
+ message="Don't have an account?"
+ linkText="Create account"
+ linkTo="/auth/sign-up"
+ />
+ </div>
</AuthLayout>
</>
);
diff --git a/apps/web/src/routes/auth/sign-up.tsx b/apps/web/src/routes/auth/sign-up.tsx
index d649e0ad1..31f95de29 100644
--- a/apps/web/src/routes/auth/sign-up.tsx
+++ b/apps/web/src/routes/auth/sign-up.tsx
@@ -2,8 +2,14 @@ import { AuthLayout } from "@/components/auth/layout";
import { SignUpForm } from "@/components/auth/sign-up-form";
import { AuthToggle } from "@/components/auth/toggle";
import PageTitle from "@/components/page-title";
+import { Button } from "@/components/ui/button";
+
import { getConfig } from "@/fetchers/config/get-config";
-import { createFileRoute, redirect } from "@tanstack/react-router";
+import { authClient } from "@/lib/auth-client";
+import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
+import { UserCheck } from "lucide-react";
+import { useState } from "react";
+import { toast } from "sonner";
export const Route = createFileRoute("/auth/sign-up")({
component: SignUp,
@@ -17,19 +23,57 @@ export const Route = createFileRoute("/auth/sign-up")({
});
function SignUp() {
+ const navigate = useNavigate();
+ const [isGuestLoading, setIsGuestLoading] = useState(false);
+
+ const handleGuestAccess = async () => {
+ setIsGuestLoading(true);
+ try {
+ const result = await authClient.signIn.anonymous();
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+ toast.success("Signed in as guest");
+ navigate({ to: "/dashboard" });
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to sign in as guest",
+ );
+ } finally {
+ setIsGuestLoading(false);
+ }
+ };
+
return (
<>
<PageTitle title="Create Account" />
<AuthLayout
title="Create account"
- subtitle="Get started with your free workspace"
+ subtitle="Get started with your workspace"
>
- <SignUpForm />
- <AuthToggle
- message="Already have an account?"
- linkText="Sign in"
- linkTo="/auth/sign-in"
- />
+ <div className="space-y-4 mt-6">
+ <Button
+ variant="outline"
+ onClick={handleGuestAccess}
+ disabled={isGuestLoading}
+ className="w-full"
+ size="sm"
+ >
+ <UserCheck className="w-4 h-4 mr-2" />
+ {isGuestLoading ? "Signing in..." : "Continue as guest"}
+ </Button>
+ <div className="flex items-center gap-4 my-4">
+ <div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-800" />
+ <span className="text-sm text-zinc-500 dark:text-zinc-400">or</span>
+ <div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-800" />
+ </div>
+ <SignUpForm />
+ <AuthToggle
+ message="Already have an account?"
+ linkText="Sign in"
+ linkTo="/auth/sign-in"
+ />
+ </div>
</AuthLayout>
</>
);
diff --git a/apps/web/src/routes/dashboard.tsx b/apps/web/src/routes/dashboard.tsx
index c2df598c6..129bc7016 100644
--- a/apps/web/src/routes/dashboard.tsx
+++ b/apps/web/src/routes/dashboard.tsx
@@ -9,7 +9,7 @@ import { useEffect } from "react";
export const Route = createFileRoute("/dashboard")({
component: DashboardIndexRouteComponent,
async beforeLoad({ context: { user } }) {
- if (user === null) {
+ if (user === undefined) {
throw redirect({
to: "/auth/sign-in",
});
diff --git a/apps/web/src/routes/dashboard/$.tsx b/apps/web/src/routes/dashboard/$.tsx
index 41eecec1d..2db42662e 100644
--- a/apps/web/src/routes/dashboard/$.tsx
+++ b/apps/web/src/routes/dashboard/$.tsx
@@ -1,3 +1,4 @@
+import useAuth from "@/components/providers/auth-provider/hooks/use-auth";
import useGetWorkspaces from "@/hooks/queries/workspace/use-get-workspaces";
import { useUserPreferencesStore } from "@/store/user-preferences";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
@@ -8,12 +9,17 @@ export const Route = createFileRoute("/dashboard/$")({
});
function CatchAllComponent() {
- const { data: workspaces } = useGetWorkspaces();
+ const { data: workspaces, isLoading } = useGetWorkspaces();
+ const { user } = useAuth();
const { activeWorkspaceId, setActiveWorkspaceId } = useUserPreferencesStore();
const navigate = useNavigate();
useEffect(() => {
- if (!workspaces) return;
+ if (!user) {
+ navigate({ to: "/auth/sign-in" });
+ }
+
+ if (!workspaces || isLoading) return;
if (workspaces.length > 0) {
if (
@@ -39,7 +45,14 @@ function CatchAllComponent() {
} else {
navigate({ to: "/dashboard/workspace/create" });
}
- }, [workspaces, activeWorkspaceId, setActiveWorkspaceId, navigate]);
+ }, [
+ workspaces,
+ activeWorkspaceId,
+ setActiveWorkspaceId,
+ navigate,
+ user,
+ isLoading,
+ ]);
return null;
}
diff --git a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/backlog.tsx b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/backlog.tsx
index fb098a0e5..08535a169 100644
--- a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/backlog.tsx
+++ b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/backlog.tsx
@@ -84,7 +84,7 @@ function RouteComponent() {
return false;
}
- if (filters.assignee && task.userEmail !== filters.assignee) {
+ if (filters.assignee && task.userId !== filters.assignee) {
return false;
}
@@ -339,7 +339,7 @@ function RouteComponent() {
<div className="flex items-center gap-1">
<span className="text-xs bg-zinc-100 dark:bg-zinc-800 px-1.5 py-0.5 rounded">
{users?.find(
- (u) => u.userEmail === filters.assignee,
+ (u) => u.userId === filters.assignee,
)?.userName || "Unknown"}
</span>
</div>
@@ -353,14 +353,14 @@ function RouteComponent() {
>
{users?.map((user) => (
<button
- key={user.userEmail}
+ key={user.userId}
type="button"
onClick={() =>
- updateFilter("assignee", user.userEmail)
+ updateFilter("assignee", user.userId)
}
className={cn(
"w-full flex items-center gap-2 px-2 py-1.5 text-xs text-left rounded-md transition-colors",
- filters.assignee === user.userEmail
+ filters.assignee === user.userId
? "bg-indigo-50 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400"
: "text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800",
)}
@@ -369,7 +369,7 @@ function RouteComponent() {
{user.userName?.charAt(0).toUpperCase()}
</div>
<span>{user.userName}</span>
- {filters.assignee === user.userEmail && (
+ {filters.assignee === user.userId && (
<Check className="h-3 w-3 ml-auto" />
)}
</button>
diff --git a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
index d760ea16f..dead82e1b 100644
--- a/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
+++ b/apps/web/src/routes/dashboard/workspace/$workspaceId/project/$projectId/board.tsx
@@ -271,7 +271,7 @@ function RouteComponent() {
<div className="flex items-center gap-1">
<span className="text-xs bg-zinc-100 dark:bg-zinc-800 px-1.5 py-0.5 rounded">
{users?.find(
- (u) => u.userEmail === filters.assignee,
+ (u) => u.userId === filters.assignee,
)?.userName || "Unknown"}
</span>
</div>
@@ -285,14 +285,14 @@ function RouteComponent() {
>
{users?.map((user) => (
<button
- key={user.userEmail}
+ key={user.userId}
type="button"
onClick={() =>
- updateFilter("assignee", user.userEmail)
+ updateFilter("assignee", user.userId)
}
className={cn(
"w-full flex items-center gap-2 px-2 py-1.5 text-xs text-left rounded-md transition-colors",
- filters.assignee === user.userEmail
+ filters.assignee === user.userId
? "bg-indigo-50 text-indigo-600 dark:bg-indigo-500/10 dark:text-indigo-400"
: "text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800",
)}
@@ -301,7 +301,7 @@ function RouteComponent() {
{user.userName?.charAt(0).toUpperCase()}
</div>
<span>{user.userName}</span>
- {filters.assignee === user.userEmail && (
+ {filters.assignee === user.userId && (
<Check className="h-3 w-3 ml-auto" />
)}
</button>
diff --git a/apps/web/src/types/time-entry/index.ts b/apps/web/src/types/time-entry/index.ts
index 48e204060..2064c6ff4 100644
--- a/apps/web/src/types/time-entry/index.ts
+++ b/apps/web/src/types/time-entry/index.ts
@@ -3,7 +3,7 @@ export type TimeEntry = {
id: string;
createdAt: string;
description: string | null;
- userEmail: string | null;
+ userId: string | null;
taskId: string;
startTime: string;
endTime: string | null;
diff --git a/apps/web/src/types/user.ts b/apps/web/src/types/user.ts
index 33ec5022b..309251408 100644
--- a/apps/web/src/types/user.ts
+++ b/apps/web/src/types/user.ts
@@ -1,13 +1 @@
-import type { client } from "@kaneo/libs";
-import type { InferResponseType } from "hono";
-
-export type User = Extract<
- InferResponseType<typeof client.me.$get>,
- { user: { id: string } }
->["user"];
-
-export type LoggedInUser = {
- name: string;
- id: string;
- email: string;
-};
+export type { User } from "better-auth/types";
diff --git a/apps/web/src/types/workspace-user/index.ts b/apps/web/src/types/workspace-user/index.ts
index 1efe6badb..a8d56c6f2 100644
--- a/apps/web/src/types/workspace-user/index.ts
+++ b/apps/web/src/types/workspace-user/index.ts
@@ -1,5 +1,5 @@
export type WorkspaceUser = {
- userEmail: string | null;
+ userId: string | null;
userName: string | null;
joinedAt: string;
status: string;
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 9f5befe7a..89b20a62f 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -1,5 +1,5 @@
import path from "node:path";
-import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
+import { tanstackRouter } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
@@ -7,7 +7,7 @@ import { defineConfig } from "vite";
export default defineConfig({
base: "/",
plugins: [
- TanStackRouterVite(),
+ tanstackRouter({ autoCodeSplitting: true }),
react({
babel: {
plugins: [["babel-plugin-react-compiler"]],
diff --git a/compose.yml b/compose.yml
new file mode 100644
index 000000000..0111c6bba
--- /dev/null
+++ b/compose.yml
@@ -0,0 +1,47 @@
+services:
+ postgres:
+ image: postgres:16-alpine
+ environment:
+ POSTGRES_DB: kaneo
+ POSTGRES_USER: kaneo_user
+ POSTGRES_PASSWORD: kaneo_password
+ ports:
+ - "5432:5432"
+ volumes:
+ - postgres_data:/var/lib/postgresql/data
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD-SHELL", "pg_isready -U kaneo_user -d kaneo"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+
+ api:
+ build:
+ context: .
+ dockerfile: apps/api/Dockerfile
+ ports:
+ - "1337:1337"
+ environment:
+ - JWT_ACCESS=change-me
+ - DATABASE_URL=postgresql://kaneo_user:kaneo_password@postgres:5432/kaneo
+ depends_on:
+ postgres:
+ condition: service_healthy
+ restart: unless-stopped
+
+ web:
+ build:
+ context: .
+ dockerfile: apps/web/Dockerfile
+ ports:
+ - "5173:5173"
+ environment:
+ - KANEO_API_URL=http://localhost:1337
+ depends_on:
+ - api
+ restart: unless-stopped
+
+volumes:
+ postgres_data:
+ name: kaneo_postgres_data
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 28486ed4c..e0d2eb7c8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -59,6 +59,9 @@ importers:
bcrypt:
specifier: ^6.0.0
version: 6.0.0
+ better-auth:
+ specifier: ^1.3.5
croner:
specifier: ^9.1.0
version: 9.1.0
@@ -70,7 +73,7 @@ importers:
version: 0.31.4
drizzle-orm:
specifier: ^0.44.3
hono:
specifier: ^4.9.2
version: 4.9.2
@@ -268,6 +271,9 @@ importers:
babel-plugin-react-compiler:
specifier: ^19.0.0-beta-714736e-20250131
version: 19.0.0-beta-ebf51a3-20250411
+ better-auth:
+ specifier: ^1.3.5
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -557,6 +563,12 @@ packages:
resolution: {integrity: sha512-jYnje+JyZG5YThjHiF28oT4SIZLnYOcSBb6+SDaFIyzDVSkXQmQQYclJ2R+YxcdmK0AX6x1E5OQNtuh3jHDrUg==}
engines: {node: '>=6.9.0'}
+ '@better-auth/[email protected]':
+ resolution: {integrity: sha512-3y/vaL5Ox33dBwgJ6ub3OPkVqr6B5xL2kgxNHG8eHZuryLyG/4JSPGqjbdRSgjuy9kALUZYDFl+ORIAxlWMSuA==}
+
+ '@better-fetch/[email protected]':
+ resolution: {integrity: sha512-rEFOE1MYIsBmoMJtQbl32PGHHXuG2hDxvEd7rUHE0vCBoFQVSDqaVs9hkZEtHCxRoY+CljXKFCOuJ8uxqw1LcA==}
+
'@biomejs/[email protected]':
resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==}
engines: {node: '>=14.21.3'}
@@ -1208,6 +1220,9 @@ packages:
'@types/react':
optional: true
+ '@hexagon/[email protected]':
+ resolution: {integrity: sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw==}
+
resolution: {integrity: sha512-icgNvC0vRYivzyuSSaUv9ttcwtN8fDyd1k3AOIBDJgYd84tXRZSS6na8X54CY/oYoFTNhEmZraW/Rb9XYwX4KA==}
engines: {node: '>=18.14.1'}
@@ -1358,6 +1373,9 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==}
+ '@levischuck/[email protected]':
+ resolution: {integrity: sha512-llBRm4dT4Z89aRsm6u2oEZ8tfwL/2l6BwpZ7JcyieouniDECM5AqNgr/y08zalEIvW3RSK4upYyybDcmjXqAow==}
+
'@mdx-js/[email protected]':
resolution: {integrity: sha512-/QxEhPAvGwbQmy1Px8F899L5Uc2KZ6JtXwlCgJmjSTBedwOZkByYcBG4GceIGPXRDsmfxhHazuS+hlOShRLeDw==}
@@ -1412,10 +1430,17 @@ packages:
cpu: [x64]
os: [win32]
+ '@noble/[email protected]':
+ resolution: {integrity: sha512-mIbq/R9QXk5/cTfESb1OKtyFnk7oc1Om/8onA1158K9/OZUQFDEVy55jVTato+xmp3XX6F6Qh0zz0Nc1AxAlRQ==}
+
resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==}
engines: {node: ^14.21.3 || >=16}
+ '@noble/[email protected]':
+ resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==}
+ engines: {node: ^14.21.3 || >=16}
+
'@nodelib/[email protected]':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -1554,6 +1579,21 @@ packages:
'@paralleldrive/[email protected]':
resolution: {integrity: sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==}
+ '@peculiar/[email protected]':
+ resolution: {integrity: sha512-YFueREq97CLslZZBI8dKzis7jMfEHSLxM+nr0Zdx1POiXFLjqqwoY5s0F1UimdBiEw/iKlHey2m56MRDv7Jtyg==}
+
+ '@peculiar/[email protected]':
+ resolution: {integrity: sha512-fJiYUBCJBDkjh347zZe5H81BdJ0+OGIg0X9z06v8xXUoql3MFeENUX0JsjCaVaU9A0L85PefLPGYkIoGpTnXLQ==}
+
+ '@peculiar/[email protected]':
+ resolution: {integrity: sha512-6PP75voaEnOSlWR9sD25iCQyLgFZHXbmxvUfnnDcfL6Zh5h2iHW38+bve4LfH7a60x7fkhZZNmiYqAlAff9Img==}
+
+ '@peculiar/[email protected]':
+ resolution: {integrity: sha512-umbembjIWOrPSOzEGG5vxFLkeM8kzIhLkgigtsOrfLKnuzxWxejAcUX+q/SoZCdemlODOcr5WiYa7+dIEzBXZQ==}
+
+ '@peculiar/[email protected]':
+ resolution: {integrity: sha512-F7mIZY2Eao2TaoVqigGMLv+NDdpwuBKU1fucHPONfzaBS4JXXCNCmfO0Z3dsy7JzKGqtDcYC1mr9JjaZQZNiuw==}
+
'@popperjs/[email protected]':
resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==}
@@ -2538,6 +2578,13 @@ packages:
'@shikijs/[email protected]':
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
+ '@simplewebauthn/[email protected]':
+ resolution: {integrity: sha512-aZnW0KawAM83fSBUgglP5WofbrLbLyr7CoPqYr66Eppm7zO86YX6rrCjRB3hQKPrL7ATvY4FVXlykZ6w6FwYYw==}
+
+ '@simplewebauthn/[email protected]':
+ resolution: {integrity: sha512-VwoDfvLXSCaRiD+xCIuyslU0HLxVggeE5BL06+GbsP2l1fGf5op8e0c3ZtKoi+vSg1q4ikjtAghC23ze2Q3H9g==}
+ engines: {node: '>=20.0.0'}
+
'@standard-schema/[email protected]':
resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
@@ -3063,6 +3110,10 @@ packages:
resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==}
+ resolution: {integrity: sha512-UOCGPYbl0tv8+006qks/dTgV9ajs97X2p0FAbyS2iyCRrmLSRolDaHdp+v/CLgnzHc3fVB+CwYiUmei7ndFcgA==}
+ engines: {node: '>=12.0.0'}
+
resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==}
engines: {node: '>=4'}
@@ -3123,6 +3174,21 @@ packages:
resolution: {integrity: sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==}
+ resolution: {integrity: sha512-jo4WTqvco7vjWNodxZyKVky9i6A7RqOb2DgS4uKwIAVucrXDv5OPxnoNE2iuEMD4Bm6l2UHRqYeqnsvsi2F23g==}
+ peerDependencies:
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ zod: ^3.25.0 || ^4.0.0
+ peerDependenciesMeta:
+ react:
+ optional: true
+ react-dom:
+ optional: true
+
+ resolution: {integrity: sha512-auqdP9lnNOli9tKpZIiv0nEIwmmyaD/RotM3Mucql+Ef88etoZi/t7Ph5LjlmZt/hiSahhNTt6YVnx6++rziXA==}
+
resolution: {integrity: sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==}
@@ -3342,6 +3408,9 @@ packages:
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
engines: {node: '>=4.0.0'}
+ resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==}
+
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
engines: {node: '>=6'}
@@ -3858,6 +3927,9 @@ packages:
resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==}
hasBin: true
+ resolution: {integrity: sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==}
+
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
@@ -3893,6 +3965,10 @@ packages:
resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-rlB0I/c6FBDWPcQoDtkxi9zIvpmnV5xoIalfCMSMCa7nuA6VGA3F54TW9mEgX4DVf10sXAWCF5fDbamI/5ZpKA==}
+ engines: {node: '>=20.0.0'}
+
resolution: {integrity: sha512-c8JK7hyE65X1MHMN+Viq9n11RRC7hgin3HhYKhrMyaXflk5GVplZ60IxyoVtzILeKr+xAJwg6zK6sjTBJ0FKYQ==}
engines: {node: '>= 12.0.0'}
@@ -4256,6 +4332,10 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
+ resolution: {integrity: sha512-k1oiVNN4hDK8NcNERSZLQiMfRzEGtfnvZvdBvey3SQbgn8Dcrk0h1I6vpxApjb10PFUflZrgJ2WEZyJQ+5v7YQ==}
+ engines: {node: ^18.0.0 || >=20.0.0}
+
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
@@ -4513,6 +4593,13 @@ packages:
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==}
+
+ resolution: {integrity: sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==}
+ engines: {node: '>=6.0.0'}
+
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
@@ -4688,6 +4775,9 @@ packages:
resolution: {integrity: sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==}
+ resolution: {integrity: sha512-OXMmJ3zRk2xeXFGfA3K+EOPHC5u7RDFG7lIOx0X1pdnhUkI8MdVrbV+sNsD80ElpUZ+MRHdyxPnFthq9VHs8uQ==}
+
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
@@ -4723,6 +4813,9 @@ packages:
resolution: {integrity: sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==}
+
resolution: {integrity: sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==}
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
@@ -4975,6 +5068,9 @@ packages:
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
+ resolution: {integrity: sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==}
+
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
@@ -5426,6 +5522,12 @@ snapshots:
'@babel/helper-string-parser': 7.27.1
'@babel/helper-validator-identifier': 7.27.1
+ '@better-auth/[email protected]':
+ dependencies:
+ uncrypto: 0.1.3
+
+ '@better-fetch/[email protected]': {}
+
'@biomejs/[email protected]':
optionalDependencies:
'@biomejs/cli-darwin-arm64': 1.9.4
@@ -5893,6 +5995,8 @@ snapshots:
- acorn
- supports-color
+ '@hexagon/[email protected]': {}
+
dependencies:
hono: 4.9.2
@@ -6006,6 +6110,8 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.4
+ '@levischuck/[email protected]': {}
+
dependencies:
'@types/estree': 1.0.7
@@ -6062,8 +6168,12 @@ snapshots:
optional: true
+ '@noble/[email protected]': {}
+
'@noble/[email protected]': {}
+ '@noble/[email protected]': {}
+
'@nodelib/[email protected]':
dependencies:
'@nodelib/fs.stat': 2.0.5
@@ -6242,6 +6352,39 @@ snapshots:
dependencies:
'@noble/hashes': 1.7.1
+ '@peculiar/[email protected]':
+ dependencies:
+ '@peculiar/asn1-schema': 2.4.0
+ asn1js: 3.0.6
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ '@peculiar/asn1-schema': 2.4.0
+ '@peculiar/asn1-x509': 2.4.0
+ asn1js: 3.0.6
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ '@peculiar/asn1-schema': 2.4.0
+ '@peculiar/asn1-x509': 2.4.0
+ asn1js: 3.0.6
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ asn1js: 3.0.6
+ pvtsutils: 1.3.6
+ tslib: 2.8.1
+
+ '@peculiar/[email protected]':
+ dependencies:
+ '@peculiar/asn1-schema': 2.4.0
+ asn1js: 3.0.6
+ pvtsutils: 1.3.6
+ tslib: 2.8.1
+
'@popperjs/[email protected]': {}
'@radix-ui/[email protected]': {}
@@ -7183,6 +7326,18 @@ snapshots:
'@shikijs/[email protected]': {}
+ '@simplewebauthn/[email protected]': {}
+
+ '@simplewebauthn/[email protected]':
+ dependencies:
+ '@hexagon/base64': 1.1.28
+ '@levischuck/tiny-cbor': 0.2.11
+ '@peculiar/asn1-android': 2.4.0
+ '@peculiar/asn1-ecc': 2.4.0
+ '@peculiar/asn1-rsa': 2.4.0
+ '@peculiar/asn1-schema': 2.4.0
+ '@peculiar/asn1-x509': 2.4.0
+
'@standard-schema/[email protected]': {}
'@standard-schema/[email protected]': {}
@@ -7751,6 +7906,12 @@ snapshots:
+ dependencies:
+ pvtsutils: 1.3.6
+ pvutils: 1.1.3
+ tslib: 2.8.1
+
dependencies:
tslib: 2.8.1
@@ -7809,6 +7970,31 @@ snapshots:
+ dependencies:
+ '@better-auth/utils': 0.2.6
+ '@better-fetch/fetch': 1.1.18
+ '@noble/ciphers': 0.6.0
+ '@noble/hashes': 1.8.0
+ '@simplewebauthn/browser': 13.1.2
+ '@simplewebauthn/server': 13.1.2
+ better-call: 1.0.13
+ defu: 6.1.4
+ jose: 5.10.0
+ kysely: 0.28.5
+ nanostores: 0.11.4
+ zod: 4.0.17
+ optionalDependencies:
+ react: 19.1.1
+ react-dom: 19.1.1([email protected])
+
+ dependencies:
+ '@better-fetch/fetch': 1.1.18
+ rou3: 0.5.1
+ set-cookie-parser: 2.7.1
+ uncrypto: 0.1.3
+
dependencies:
bindings: 1.5.0
@@ -8027,6 +8213,8 @@ snapshots:
optional: true
+
@@ -8054,12 +8242,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
optionalDependencies:
'@types/better-sqlite3': 7.6.13
'@types/pg': 8.15.5
better-sqlite3: 11.10.0
bun-types: 1.2.8
+ kysely: 0.28.5
pg: 8.16.3
@@ -8567,6 +8756,8 @@ snapshots:
+
@@ -8590,6 +8781,8 @@ snapshots:
+
optional: true
@@ -9174,6 +9367,8 @@ snapshots:
+
optional: true
@@ -9492,6 +9687,12 @@ snapshots:
+ dependencies:
+ tslib: 2.8.1
+
+
@@ -9752,6 +9953,8 @@ snapshots:
+
dependencies:
queue-microtask: 1.2.3
@@ -9780,6 +9983,8 @@ snapshots:
+
dependencies:
color: 4.2.3
@@ -10065,6 +10270,8 @@ snapshots:
+