feat: 更新JWKS token创建逻辑,支持refresh token选项

This commit is contained in:
2026-03-03 19:10:57 +08:00
parent bb4096ce7e
commit d2913dd32d
3 changed files with 24 additions and 14 deletions

View File

@@ -9,12 +9,14 @@ app.route({
middleware: ['auth'],
metadata: {
args: {
loginType: z.enum(['jwks']).optional(),
loginType: z.enum(['jwks']).optional().describe('登录类型默认为jwks'),
hasRefreshToken: z.boolean().optional().describe('是否需要refresh token默认为false'),
}
}
}).define(async (ctx) => {
const user = await UserModel.getUserByToken(ctx.query.token);
const loginType = ctx.query?.loginType ?? 'jwks';
const hasRefreshToken = ctx.query?.hasRefreshToken ?? false;
if (!user) {
ctx.throw(404, 'user not found');
}
@@ -28,6 +30,7 @@ app.route({
}
const value = await user.createToken(null, loginType, {
expire: expire, // 24小时过期
hasRefreshToken: hasRefreshToken,
})
ctx.body = value
}).addTo(app)