mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 13:03:08 +00:00
API: fire SB_SESSION_REMOVE upon logging out a session
This commit is contained in:
1 parent
3fdc6a54aa
commit
f9f1d8776b
2 files changed
+14
-2
No files matched your search
@@ -18,7 +18,7 @@
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Session } from "@spacebar/util";
|
||||
import { emitEvent, Session } from "@spacebar/util";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
export default router;
|
||||
@@ -42,5 +42,12 @@ router.post(
|
||||
if (req.session) await Session.remove(req.session);
|
||||
|
||||
res.status(204).send();
|
||||
|
||||
if (req.session)
|
||||
await emitEvent({
|
||||
session_id: req.session.session_id,
|
||||
event: "SB_SESSION_REMOVE",
|
||||
origin: "Self logout",
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
import { route } from "@spacebar/api";
|
||||
import { createHash } from "node:crypto";
|
||||
import { Session, Snowflake } from "@spacebar/util";
|
||||
import { emitEvent, Session, Snowflake } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { SessionsLogoutSchema } from "../../../schemas/api/users/SessionsSchemas";
|
||||
import { In } from "typeorm";
|
||||
@@ -69,6 +69,11 @@ router.post(
|
||||
|
||||
for (const session of sessions) {
|
||||
await session.remove();
|
||||
await emitEvent({
|
||||
session_id: session.session_id,
|
||||
event: "SB_SESSION_REMOVE",
|
||||
origin: "Sessions logout",
|
||||
});
|
||||
}
|
||||
res.status(204).send();
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user