fix: 获取token之后要回填到userAuth记录中
This commit is contained in:
parent
d7b34fb3f6
commit
6f5dead6cc
|
|
@ -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(),
|
||||
|
|
@ -243,7 +256,7 @@ const oauthUserInfoEndpoint: Endpoint<EntityDict, BackendRuntimeContext<EntityDi
|
|||
nickname: tokenRecord.user.nickname,
|
||||
birth: tokenRecord.user.birth,
|
||||
gender: tokenRecord.user.gender,
|
||||
avatarUrl: avatarUrl,
|
||||
avatarUrl: avatarUrl,
|
||||
},
|
||||
error: null
|
||||
}
|
||||
|
|
@ -366,7 +379,7 @@ const refreshTokenEndpoint: Endpoint<EntityDict, BackendRuntimeContext<EntityDic
|
|||
const newRefreshToken = randomUUID();
|
||||
const expiresIn = 3600; // 1 hour
|
||||
const refreshTokenExpiresIn = 86400 * 30; // 30 days
|
||||
|
||||
|
||||
await context.operate("oauthToken", {
|
||||
id: await generateNewIdAsync(),
|
||||
action: "update",
|
||||
|
|
|
|||
|
|
@ -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