Removing session API.
This commit is contained in:
parent
6c926ab2d7
commit
1b952d29a3
|
@ -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
|
|
|
@ -6,7 +6,6 @@ const templateRoutes = require("./global/templates")
|
||||||
const emailRoutes = require("./global/email")
|
const emailRoutes = require("./global/email")
|
||||||
const authRoutes = require("./global/auth")
|
const authRoutes = require("./global/auth")
|
||||||
const roleRoutes = require("./global/roles")
|
const roleRoutes = require("./global/roles")
|
||||||
const sessionRoutes = require("./global/sessions")
|
|
||||||
const environmentRoutes = require("./system/environment")
|
const environmentRoutes = require("./system/environment")
|
||||||
const tenantsRoutes = require("./system/tenants")
|
const tenantsRoutes = require("./system/tenants")
|
||||||
const statusRoutes = require("./system/status")
|
const statusRoutes = require("./system/status")
|
||||||
|
@ -23,7 +22,6 @@ exports.routes = [
|
||||||
templateRoutes,
|
templateRoutes,
|
||||||
tenantsRoutes,
|
tenantsRoutes,
|
||||||
emailRoutes,
|
emailRoutes,
|
||||||
sessionRoutes,
|
|
||||||
roleRoutes,
|
roleRoutes,
|
||||||
environmentRoutes,
|
environmentRoutes,
|
||||||
statusRoutes,
|
statusRoutes,
|
||||||
|
|
Loading…
Reference in New Issue