mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-06-29 13:43:58 +00:00
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
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m9s
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
11
lib/auth.ts
11
lib/auth.ts
@ -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({
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user