feat: add complex user invitation and management features

- Implemented complex member and invitation schemas using Zod for validation.
- Created new API endpoints for inviting, accepting, revoking, and canceling complex user invitations.
- Developed handlers for managing complex users, including listing, inviting, revoking, and canceling invitations.
- Added frontend components for displaying and managing complex users and invitations.
- Introduced session storage management for pending invitations.
- Integrated Gravatar for user avatars based on email.
- Created database migration for complex invitations table.
This commit is contained in:
Jose Selesan
2026-04-22 15:30:04 -03:00
parent 5f2a7fd494
commit 6ad4fc9ee9
37 changed files with 1935 additions and 78 deletions

View File

@@ -1,37 +1,34 @@
import { dash } from '@better-auth/infra';
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { openAPI } from 'better-auth/plugins';
import { db } from './prisma';
import { dash } from "@better-auth/infra";
export const auth = betterAuth({
database: prismaAdapter(db, {
provider: 'postgresql',
}),
secret: process.env.BETTER_AUTH_SECRET,
baseURL: process.env.BETTER_AUTH_URL,
session: {
cookieCache: {
enabled: false,
},
database: prismaAdapter(db, {
provider: 'postgresql',
}),
secret: process.env.BETTER_AUTH_SECRET,
baseURL: process.env.BETTER_AUTH_URL,
session: {
cookieCache: {
enabled: false,
},
emailAndPassword: {
enabled: true,
},
emailAndPassword: {
enabled: true,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
},
trustedOrigins: [
process.env.APP_BASE_URL ?? 'http://localhost:5173',
process.env.BETTER_AUTH_URL ?? 'http://localhost:3000',
],
plugins: [
openAPI(),
dash()
],
},
trustedOrigins: [
process.env.APP_BASE_URL ?? 'http://localhost:5173',
process.env.BETTER_AUTH_URL ?? 'http://localhost:3000',
],
plugins: [openAPI(), dash()],
});
export type Session = typeof auth.$Infer.Session.session;

View File

@@ -0,0 +1,17 @@
import { createHash } from 'node:crypto';
function getGravatarUrl(email: string): string {
const hash = createHash('md5').update(email.trim().toLowerCase()).digest('hex');
return `https://www.gravatar.com/avatar/${hash}?d=identicon`;
}
export function resolveAvatarUrl(input: {
email: string;
image?: string | null;
}): string {
if (input.image) {
return input.image;
}
return getGravatarUrl(input.email);
}