mirror of https://github.com/Budibase/budibase.git
committed by
GitHub
3 changed files with 0 additions and 53 deletions
@ -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.", |
|||
} |
|||
} |
|||
@ -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 |
|||
Loading…
Reference in new issue