mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 13:32:08 +01:00
feat: Add authentication and session management with NextAuth.js and Prisma [broken]
- Implemented API session retrieval in `lib/api-auth.ts` to manage user sessions. - Created authentication options in `lib/auth-options.ts` using NextAuth.js with credentials provider. - Added migration scripts to create necessary tables for authentication in `migrations/0002_create_auth_tables.sql` and `prisma/migrations/20250601033219_add_nextauth_tables/migration.sql`. - Configured ESLint with Next.js and TypeScript support in `eslint.config.mjs`. - Updated Next.js configuration in `next.config.ts` for Cloudflare compatibility. - Defined Cloudflare Worker configuration in `open-next.config.ts` and `wrangler.jsonc`. - Enhanced type definitions for authentication in `types/auth.d.ts`. - Created a Cloudflare Worker entry point in `src/index.ts.backup` to handle API requests and responses.
This commit is contained in:
50
types/auth.d.ts
vendored
Normal file
50
types/auth.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import { DefaultSession } from "next-auth";
|
||||
|
||||
declare module "next-auth" {
|
||||
/**
|
||||
* Returned by `auth`, `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
|
||||
*/
|
||||
interface Session {
|
||||
user: {
|
||||
/** The user's unique id. */
|
||||
id: string;
|
||||
/** The user's role (admin, user, etc.) */
|
||||
role: string;
|
||||
/** The user's company ID */
|
||||
companyId: string;
|
||||
/** The user's company name */
|
||||
company: string;
|
||||
} & DefaultSession["user"];
|
||||
}
|
||||
|
||||
/**
|
||||
* The shape of the user object returned in the OAuth providers' `profile` callback,
|
||||
* or the second parameter of the `session` callback, when using a database.
|
||||
*/
|
||||
interface User {
|
||||
/** The user's unique id. */
|
||||
id: string;
|
||||
/** The user's email address. */
|
||||
email?: string;
|
||||
/** The user's name. */
|
||||
name?: string;
|
||||
/** The user's role (admin, user, etc.) */
|
||||
role: string;
|
||||
/** The user's company ID */
|
||||
companyId: string;
|
||||
/** The user's company name */
|
||||
company: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "next-auth/jwt" {
|
||||
/** Returned by the `jwt` callback and `auth`, when using JWT sessions */
|
||||
interface JWT {
|
||||
/** The user's role */
|
||||
role: string;
|
||||
/** The user's company ID */
|
||||
companyId: string;
|
||||
/** The user's company name */
|
||||
company: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user