mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-03 06:48:21 +00:00
refactor: streamline authentication flow by removing unused code, replacing custom auth utilities with NextAuth, and updating session handling in components
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 5m56s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 5m56s
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/lib/db";
|
||||
import type { GroupProfile, MacAddress, OmadaResponse } from "@/lib/types";
|
||||
import { formatMacAddress } from "@/lib/utils";
|
||||
import { revalidatePath } from "next/cache";
|
||||
@ -124,11 +123,11 @@ export async function blockDevice({
|
||||
if (!macAddress) {
|
||||
throw new Error("macAddress is a required parameter");
|
||||
}
|
||||
const device = await prisma.device.findFirst({
|
||||
where: {
|
||||
mac: macAddress,
|
||||
},
|
||||
});
|
||||
// const device = await prisma.device.findFirst({
|
||||
// where: {
|
||||
// mac: macAddress,
|
||||
// },
|
||||
// });
|
||||
try {
|
||||
const baseUrl: string = process.env.OMADA_BASE_URL || "";
|
||||
const url: string = `${baseUrl}/api/v2/sites/${process.env.OMADA_SITE_ID}/cmd/clients/${formatMacAddress(macAddress)}/${type}`;
|
||||
@ -146,16 +145,16 @@ export async function blockDevice({
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
await prisma.device.update({
|
||||
where: {
|
||||
id: device?.id,
|
||||
},
|
||||
data: {
|
||||
reasonForBlocking: type === "block" ? reason : "",
|
||||
blocked: type === "block",
|
||||
blockedBy: blockedBy,
|
||||
},
|
||||
});
|
||||
// await prisma.device.update({
|
||||
// where: {
|
||||
// id: device?.id,
|
||||
// },
|
||||
// data: {
|
||||
// reasonForBlocking: type === "block" ? reason : "",
|
||||
// blocked: type === "block",
|
||||
// blockedBy: blockedBy,
|
||||
// },
|
||||
// });
|
||||
revalidatePath("/parental-control");
|
||||
} catch (error) {
|
||||
console.error("Error blocking device:", error);
|
||||
|
Reference in New Issue
Block a user