adds user accounts, service requests, dashboard, admin panel, better layout, db+altcha+auth support

This commit is contained in:
Aidan 2025-07-07 20:01:59 -04:00
parent dfbc3cade9
commit 0043a5bf3c
40 changed files with 3981 additions and 188 deletions

4
util/auth-client.ts Normal file
View file

@ -0,0 +1,4 @@
import { createAuthClient } from "better-auth/react"
export const authClient = createAuthClient({
baseURL: process.env.BETTER_AUTH_URL!
})

27
util/auth.ts Normal file
View file

@ -0,0 +1,27 @@
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "../db";
import * as schema from "../db/schema";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema,
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
},
session: {
expiresIn: 60 * 60 * 24 * 7,
},
user: {
additionalFields: {
role: {
type: "string",
required: false,
defaultValue: "user"
}
}
}
});

22
util/captcha.ts Normal file
View file

@ -0,0 +1,22 @@
import { verifySolution } from "altcha-lib";
export async function verifyCaptcha(token: string): Promise<boolean> {
const hmacKey = process.env.ALTCHA_SECRET;
if (!hmacKey) {
console.error("ALTCHA_SECRET is not set");
return false;
}
if (!token) {
return false;
}
try {
const isValid = await verifySolution(token, hmacKey);
return isValid;
} catch (error) {
console.error("[ALTCHA] Error:", error);
return false;
}
}