Removing session API.

This commit is contained in:
mike12345567 2022-08-05 11:39:28 +01:00
parent 6c926ab2d7
commit 1b952d29a3
3 changed files with 0 additions and 53 deletions

View File

@ -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.",
}
}

View File

@ -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

View File

@ -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,