mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-12 12:04:16 +00:00
22 lines
525 B
JavaScript
22 lines
525 B
JavaScript
import { Session } from "@db_models"
|
|
|
|
export default {
|
|
middlewares: ["withAuthentication"],
|
|
fn: async (req) => {
|
|
const { token, session } = req.auth
|
|
|
|
const deletedSession = await Session.findOneAndDelete({
|
|
user_id: session.user_id,
|
|
token: token,
|
|
})
|
|
|
|
if (session) {
|
|
return {
|
|
message: "Session deleted",
|
|
session: deletedSession
|
|
}
|
|
}
|
|
|
|
throw new OperationError(404, "Session not found")
|
|
}
|
|
} |