mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
27 lines
661 B
JavaScript
Executable File
27 lines
661 B
JavaScript
Executable File
import { Session } from "@db_models"
|
|
|
|
export default {
|
|
method: "DELETE",
|
|
route: "/current",
|
|
middlewares: ["withAuthentication"],
|
|
fn: async (req, res) => {
|
|
const token = req.jwtToken
|
|
const user_id = req.user._id.toString()
|
|
|
|
if (typeof token === "undefined") {
|
|
return res.status(400).json("Cannot access to token")
|
|
}
|
|
|
|
const session = await Session.findOneAndDelete({ user_id, token })
|
|
|
|
if (session) {
|
|
return res.json({
|
|
message: "done",
|
|
})
|
|
}
|
|
|
|
return res.status(404).json({
|
|
error: "Session not found",
|
|
})
|
|
},
|
|
} |