Files
hydra/src/main/events/auth/get-session-hash.ts
Chubby Granny Chaser ac27438a35 ci: adding sentry
2024-06-28 20:27:22 +01:00

19 lines
561 B
TypeScript

import jwt from "jsonwebtoken";
import * as Sentry from "@sentry/electron/main";
import { userAuthRepository } from "@main/repository";
import { registerEvent } from "../register-event";
const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
const auth = await userAuthRepository.findOne({ where: { id: 1 } });
if (!auth) return null;
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;
Sentry.setContext("sessionId", payload.sessionId);
return payload.sessionId;
};
registerEvent("getSessionHash", getSessionHash);