Refactor authentication middleware to use native fetch, update dependencies, and enhance error handling. Add new error boundary component for dashboard and improve user verification UI. Update payment handling and device management components for better user experience. Adjust CSS for error backgrounds and refine input read-only components with validation indicators.
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m9s

This commit is contained in:
2025-01-15 10:35:03 +05:00
parent d14b0b35a3
commit 8ffabb1fcb
23 changed files with 535 additions and 303 deletions

View File

@ -1,10 +1,15 @@
"use server";
import { headers } from "next/headers";
import { cache } from "react";
import { auth } from "./auth";
export async function getCurrentUser() {
const getCurrentUserCache = cache(async () => {
const session = await auth.api.getSession({
headers: await headers(),
});
return session?.user;
});
export async function getCurrentUser() {
return await getCurrentUserCache();
}

View File

@ -1,11 +1,16 @@
import { sendOtp } from "@/actions/auth-actions";
import { PrismaClient } from "@prisma/client";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { phoneNumber } from "better-auth/plugins";
import prisma from "./db";
const prisma = new PrismaClient();
export const auth = betterAuth({
session: {
cookieCache: {
enabled: true,
maxAge: 10 * 60, // Cache duration in seconds
},
},
trustedOrigins: process.env.BETTER_AUTH_TRUSTED_ORIGINS?.split(",") || [
"localhost:3000",
],
@ -25,7 +30,7 @@ export const auth = betterAuth({
},
},
database: prismaAdapter(prisma, {
provider: "sqlite", // or "mysql", "postgresql", ...etc
provider: "postgresql", // or "mysql", "postgresql", ...etc
}),
plugins: [
phoneNumber({

View File

@ -35,7 +35,6 @@ export async function VerifyUserDetails({ user }: { user: User }) {
user.id_card === nationalData.nic &&
user.name === nationalData.name_en &&
user.address === nationalData.house_name_en &&
phoneNumber === nationalData.primary_contact &&
age >= 18
) {
return true;