mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 13:22:01 +00:00
- Added new omada-actions.ts file to handle fetching and updating device groups in Omada. - Updated authMiddleware to include new payment routes. - Enhanced createPayment function to add devices to a group upon successful payment verification. - Improved payment verification process to include device management. - Refactored PaymentsTable and DevicesToPay components for better UI and state handling. - Removed unused hasSession function from auth-guard.ts for cleaner code.
26 lines
681 B
TypeScript
26 lines
681 B
TypeScript
import { betterFetch } from "@better-fetch/fetch";
|
|
import type { Session } from "better-auth/types";
|
|
import { type NextRequest, NextResponse } from "next/server";
|
|
|
|
export default async function authMiddleware(request: NextRequest) {
|
|
const { data: session } = await betterFetch<Session>(
|
|
"/api/auth/get-session",
|
|
{
|
|
baseURL: request.nextUrl.origin,
|
|
headers: {
|
|
//get the cookie from the request
|
|
cookie: request.headers.get("cookie") || "",
|
|
},
|
|
},
|
|
);
|
|
|
|
if (!session) {
|
|
return NextResponse.redirect(new URL("/login", request.url));
|
|
}
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ["/devices", "/", "/payments", "/payments/:paymentId"],
|
|
};
|