ok
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user