feat: 添加 /api/auth/me 调试端点查看当前用户权限
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -78,4 +78,18 @@ app.get('/exchange', async (c) => {
|
||||
}
|
||||
});
|
||||
|
||||
/** GET /api/auth/me — 查看当前用户信息(调试用) */
|
||||
app.get('/me', async (c) => {
|
||||
const authHeader = c.req.header('Authorization');
|
||||
if (!authHeader?.startsWith('Bearer ')) {
|
||||
return c.json({ error: 'No token' }, 401);
|
||||
}
|
||||
try {
|
||||
const payload = jwt.verify(authHeader.slice(7), JWT_SECRET) as JwtPayload;
|
||||
return c.json(payload);
|
||||
} catch {
|
||||
return c.json({ error: 'Invalid token' }, 401);
|
||||
}
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user