feat: implement email-optional authentication

- Make email field optional in database schema
- Update user creation to handle null emails
- Enhance notification service to gracefully skip email for users without email addresses
- Add validation in email service for null/empty emails
- Create comprehensive documentation for Clerk configuration
- Add test script for email-optional functionality
- Update all user creation points (userService, eventController, reportController)

Users can now sign up with just username and password. Email notifications
are gracefully skipped for users without email addresses, while in-app
notifications continue to work for all users.

Closes: Email-optional authentication requirement
This commit is contained in:
2025-11-18 18:02:10 +00:00
parent eed129347b
commit e2ff6f04f3
13 changed files with 1390 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ async function findOrCreateUser(clerkId: string): Promise<string> {
user = await prisma.user.create({
data: {
clerkId,
email: clerkUser.emailAddresses[0]?.emailAddress || `${clerkId}@temp.com`,
email: clerkUser.emailAddresses[0]?.emailAddress || null,
username: clerkUser.username || `user_${clerkId.substring(0, 8)}`,
firstName: clerkUser.firstName,
lastName: clerkUser.lastName,