Add email notifications via Resend

- src/lib/email.ts: HTML templates for 4 email types (Second Brain design)
- Welcome email on user registration (Better Auth databaseHooks)
- Course access email when admin grants enrollment
- Homework submitted email to all admins/curators (first submission only)
- Feedback received email to student with feedback text and lesson link
- Update TECHNICAL.md: Resend domain, from-address, email vars, Stage 3 summary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-07 14:46:46 +05:00
parent 9bc18247df
commit 6975a9f97e
6 changed files with 195 additions and 4 deletions
+10
View File
@@ -3,6 +3,7 @@ import { prismaAdapter } from "better-auth/adapters/prisma";
import { admin } from "better-auth/plugins";
import { prisma } from "./prisma";
import bcrypt from "bcryptjs";
import { sendWelcomeEmail } from "./email";
export const auth = betterAuth({
database: prismaAdapter(prisma, {
@@ -16,6 +17,15 @@ export const auth = betterAuth({
verify: ({ hash, password }) => bcrypt.compare(password, hash),
},
},
databaseHooks: {
user: {
create: {
after: async (user) => {
await sendWelcomeEmail(user.email, user.name);
},
},
},
},
plugins: [
admin({
defaultRole: "student",