feat: 更新JWKS token创建逻辑,支持refresh token选项
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user