From 1b952d29a3181323cd3501a975deb5f180bbef9f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 5 Aug 2022 11:39:28 +0100 Subject: [PATCH] Removing session API. --- .../src/api/controllers/global/sessions.js | 37 ------------------- .../worker/src/api/routes/global/sessions.js | 14 ------- packages/worker/src/api/routes/index.js | 2 - 3 files changed, 53 deletions(-) delete mode 100644 packages/worker/src/api/controllers/global/sessions.js delete mode 100644 packages/worker/src/api/routes/global/sessions.js diff --git a/packages/worker/src/api/controllers/global/sessions.js b/packages/worker/src/api/controllers/global/sessions.js deleted file mode 100644 index 4a334037d4..0000000000 --- a/packages/worker/src/api/controllers/global/sessions.js +++ /dev/null @@ -1,37 +0,0 @@ -const { - getAllSessions, - getUserSessions, - invalidateSessions, -} = require("@budibase/backend-core/sessions") - -exports.fetch = async ctx => { - ctx.body = await getAllSessions() -} - -exports.find = async ctx => { - const { userId } = ctx.params - const sessions = await getUserSessions(userId) - ctx.body = sessions.map(session => session.value) -} - -exports.invalidateUser = async ctx => { - const { userId } = ctx.params - await invalidateSessions(userId) - ctx.body = { - message: "User sessions invalidated", - } -} - -exports.selfSessions = async ctx => { - const userId = ctx.user._id - ctx.body = await getUserSessions(userId) -} - -exports.invalidateSession = async ctx => { - const userId = ctx.user._id - const { sessionId } = ctx.params - await invalidateSessions(userId, sessionId) - ctx.body = { - message: "Session invalidated successfully.", - } -} diff --git a/packages/worker/src/api/routes/global/sessions.js b/packages/worker/src/api/routes/global/sessions.js deleted file mode 100644 index 6ab4ad8e59..0000000000 --- a/packages/worker/src/api/routes/global/sessions.js +++ /dev/null @@ -1,14 +0,0 @@ -const Router = require("@koa/router") -const controller = require("../../controllers/global/sessions") -const { adminOnly } = require("@budibase/backend-core/auth") - -const router = Router() - -router - .get("/api/global/sessions", adminOnly, controller.fetch) - .get("/api/global/sessions/self", controller.selfSessions) - .get("/api/global/sessions/:userId", adminOnly, controller.find) - .delete("/api/global/sessions/:userId", adminOnly, controller.invalidateUser) - .delete("/api/global/sessions/self/:sessionId", controller.invalidateSession) - -module.exports = router diff --git a/packages/worker/src/api/routes/index.js b/packages/worker/src/api/routes/index.js index e112d4def3..550d14a9a3 100644 --- a/packages/worker/src/api/routes/index.js +++ b/packages/worker/src/api/routes/index.js @@ -6,7 +6,6 @@ const templateRoutes = require("./global/templates") const emailRoutes = require("./global/email") const authRoutes = require("./global/auth") const roleRoutes = require("./global/roles") -const sessionRoutes = require("./global/sessions") const environmentRoutes = require("./system/environment") const tenantsRoutes = require("./system/tenants") const statusRoutes = require("./system/status") @@ -23,7 +22,6 @@ exports.routes = [ templateRoutes, tenantsRoutes, emailRoutes, - sessionRoutes, roleRoutes, environmentRoutes, statusRoutes,