fix: 获取token之后要回填到userAuth记录中
This commit is contained in:
parent
6e6b8eb3b9
commit
d8c358f463
|
|
@ -108,11 +108,12 @@ const oauthTokenEndpoint: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>
|
|||
const refreshTokenExpiresIn = 86400 * 30; // 30 days
|
||||
|
||||
// create
|
||||
const tokenId = await generateNewIdAsync();
|
||||
await context.operate("oauthToken", {
|
||||
id: await generateNewIdAsync(),
|
||||
action: "create",
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
id: tokenId,
|
||||
accessToken: genaccessToken,
|
||||
refreshToken: refreshToken,
|
||||
userId: authCodeRecord.userId,
|
||||
|
|
@ -122,6 +123,18 @@ const oauthTokenEndpoint: Endpoint<EntityDict, BackendRuntimeContext<EntityDict>
|
|||
}
|
||||
}, {})
|
||||
|
||||
// 创建记录
|
||||
await context.operate("oauthUserAuthorization", {
|
||||
id: await generateNewIdAsync(),
|
||||
action: "update",
|
||||
data: {
|
||||
tokenId: tokenId,
|
||||
},
|
||||
filter: {
|
||||
codeId: authCodeRecord.id,
|
||||
}
|
||||
}, {})
|
||||
|
||||
// 标记code为已使用
|
||||
await context.operate("oauthAuthorizationCode", {
|
||||
id: await generateNewIdAsync(),
|
||||
|
|
|
|||
|
|
@ -68,6 +68,21 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
|
|||
revoked: '#6c757d',
|
||||
}
|
||||
}
|
||||
},
|
||||
indexes: [
|
||||
// 根据授权码查询唯一记录
|
||||
{
|
||||
name: 'idx_code_id',
|
||||
attributes: [
|
||||
{
|
||||
name: 'code',
|
||||
direction: 'ASC',
|
||||
}
|
||||
],
|
||||
config: {
|
||||
unique: true,
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue