This commit is contained in:
Your Name
2026-08-06 10:09:07 +00:00
parent 3a217f0dd0
commit ae04fe4092
15 changed files with 837 additions and 8 deletions
+10 -1
View File
@@ -1,6 +1,6 @@
import type { FastifyInstance } from 'fastify'
import type { TrueApiEnv } from '../config.js'
import { getAuthKey, signIn, clearToken, getAuthStatus, setTokenDirect } from '../services/auth-service.js'
import { getAuthKey, signIn, clearToken, getAuthStatus, setTokenDirect, getCachedToken } from '../services/auth-service.js'
import { AppError, extractDebugInfo } from '../services/cises-service.js'
const VALID_ENVS = ['sandbox', 'prod']
@@ -71,6 +71,15 @@ export async function authRoutes(app: FastifyInstance): Promise<void> {
return getAuthStatus(env)
})
app.get('/auth/token', async (request, reply) => {
const env = parseEnv(request.query as Record<string, string>)
const token = getCachedToken(env)
if (!token) {
return reply.status(404).send({ error: 'Token not found' })
}
return { token }
})
app.post('/auth/logout', async (request) => {
const env = parseEnv(request.query as Record<string, string>)
clearToken(env)