Files
hydra/src/main/events/auth/get-session-hash.ts
Chubby Granny Chaser 9ef6329799 feat: adding session hash
2024-06-21 02:37:49 +01:00

15 lines
457 B
TypeScript

import jwt from "jsonwebtoken";
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;
return payload.sessionId;
};
registerEvent("getSessionHash", getSessionHash);