- Add user management with roles and permissions (RBAC) - Implement OAuth2 service provider supporting 4 grant types: authorization_code, password, client_credentials, refresh_token - Add JWT authentication with 7-day expiry - Add admin API for users, roles and OAuth clients management - Add CLI tool for user management (scripts/user-cli.js) - Add collapsible sidebar layout with login dialog - Add user management page and OAuth client management page - Add server middleware for auth token verification - Add seed script for initial data (admin/admin123)
22 lines
542 B
TypeScript
22 lines
542 B
TypeScript
import { verifyToken } from '../../utils/jwt'
|
|
import { revokeToken } from '../../modules/oauth'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const authHeader = getHeader(event, 'authorization')
|
|
|
|
if (authHeader && authHeader.startsWith('Bearer ')) {
|
|
const token = authHeader.substring(7)
|
|
revokeToken(token, 'access')
|
|
}
|
|
|
|
const body = await readBody(event).catch(() => ({}))
|
|
if (body.refreshToken) {
|
|
revokeToken(body.refreshToken, 'refresh')
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
message: '登出成功'
|
|
}
|
|
})
|