Shorten session length, change device ID calc

This commit is contained in:
Darren Clarke 2024-11-25 12:20:49 +01:00
parent 84731c9e9a
commit 130554d86b
3 changed files with 13 additions and 5 deletions

View file

@ -75,7 +75,6 @@ export const updateTicketAction = async (
ticketID: string, ticketID: string,
ticketInfo: Record<string, any>, ticketInfo: Record<string, any>,
) => { ) => {
console.log({ ticketID, ticketInfo });
try { try {
const input = {}; const input = {};
if (ticketInfo.state) { if (ticketInfo.state) {

View file

@ -109,6 +109,9 @@ export const authOptions: NextAuthOptions = {
signOut: "/logout", signOut: "/logout",
}, },
providers, providers,
session: {
maxAge: 7 * 24 * 60 * 60,
},
secret: process.env.NEXTAUTH_SECRET, secret: process.env.NEXTAUTH_SECRET,
callbacks: { callbacks: {
signIn: async ({ user }) => { signIn: async ({ user }) => {

View file

@ -1,13 +1,19 @@
import { getServerSession } from "app/_lib/authentication"; import { getServerSession } from "app/_lib/authentication";
import { cookies } from "next/headers"; import { cookies, headers } from "next/headers";
import crypto from "crypto";
const getHeaders = async () => { const getHeaders = async () => {
const userAgent = (await headers()).get("user-agent");
const allCookies = (await cookies()).getAll(); const allCookies = (await cookies()).getAll();
const hashedUserAgent = crypto
.createHash("sha256")
.update(userAgent)
.digest("hex");
const session = await getServerSession(); const session = await getServerSession();
const headers = { const finalHeaders = {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
"X-Browser-Fingerprint": `${session.expires}`, "X-Browser-Fingerprint": hashedUserAgent,
// @ts-ignore // @ts-ignore
"X-CSRF-Token": session.user.zammadCsrfToken, "X-CSRF-Token": session.user.zammadCsrfToken,
Cookie: allCookies Cookie: allCookies
@ -15,7 +21,7 @@ const getHeaders = async () => {
.join("; "), .join("; "),
}; };
return headers; return finalHeaders;
}; };
interface ExecuteGraphQLOptions { interface ExecuteGraphQLOptions {