Yggdrasil/routes/authserver/invalidate.js
azures04 0b1662d8ca Initial project structure and core modules
Add environment example, update .gitignore, and switch license to AGPL v3. Introduce error handling classes, ESLint config, and main modules for database, logging, certificate management, and utility functions. Add authentication routes, schemas, and service layer for a modular REST API. Update README and set up repository structure for further development.
2025-12-23 15:59:43 +01:00

20 lines
684 B
JavaScript

const express = require("express")
const router = express.Router()
const authService = require("../../services/authService")
const YggdrasilError = require("../../errors/YggdrasilError")
const { DefaultError } = require("../../errors/errors")
router.post("/", async (req, res) => {
const { accessToken, clientToken } = req.body
try {
await authService.invalidate({ accessToken, clientToken })
res.sendStatus(204)
} catch (err) {
if (err instanceof DefaultError) {
throw new YggdrasilError(err.code, err.error || "ForbiddenOperationException", err.message, "Invalid token.")
}
throw err
}
})
module.exports = router