Fix access token bug
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
Sync Main to Dev / sync-commits (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled

This commit is contained in:
Konstantin Wohlwend 2025-10-10 19:48:33 -07:00
parent 7416a370c7
commit b7a2a04a16

View File

@ -97,6 +97,7 @@ export class OAuthModel implements AuthorizationCodeModel {
assertScopeIsValid(scope);
const tenancy = await getSoleTenancyFromProjectBranch(...getProjectBranchFromClientId(client.id));
console.log("generateAccessToken", client, user, scope);
const refreshTokenObj = await this._getOrCreateRefreshTokenObj(client, user, scope);
return await generateAccessTokenFromRefreshTokenIfValid({
@ -235,6 +236,11 @@ export class OAuthModel implements AuthorizationCodeModel {
const tenancy = await getTenancy(token.tenancyId);
if (!tenancy) {
// this may trigger when the tenancy was deleted after the token was created
return false;
}
if (!(await isRefreshTokenValid({ tenancy, refreshTokenObj: token }))) {
return false;
}
@ -311,6 +317,8 @@ export class OAuthModel implements AuthorizationCodeModel {
},
});
console.log("getAuthorizationCode", authorizationCode, code);
if (!code) {
return false;
}
@ -328,6 +336,7 @@ export class OAuthModel implements AuthorizationCodeModel {
codeChallenge: code.codeChallenge,
codeChallengeMethod: code.codeChallengeMethod,
client: {
// TODO once we support branches, the branch ID should be included here
id: tenancy.project.id,
grants: ["authorization_code", "refresh_token"],
},