Skip to content

Commit

Permalink
Merge branch 'main' into harshbhat/unkey-springboot
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsbhat authored Oct 17, 2024
2 parents a5da055 + 8b37287 commit b7e8985
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ dist
.dev.vars
.wrangler
.vitest
.react-email
.react-email

.secrets.json
secrets.ts
25 changes: 23 additions & 2 deletions apps/api/src/pkg/keys/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,29 @@ export class KeyService {
return Ok({ valid: false, code: "NOT_FOUND" });
}

if ((data.forWorkspace && !data.forWorkspace.enabled) || !data.workspace.enabled) {
return Err(new DisabledWorkspaceError(data.workspace.id));
this.logger.info("data from cache or db", {
data,
});
// Quick fix
if (!data.workspace) {
this.logger.warn("workspace not found, trying again", {
workspace: data.key.workspaceId,
});
await this.cache.keyByHash.remove(keyHash);
const ws = await this.db.primary.query.workspaces.findFirst({
where: (table, { eq }) => eq(table.id, data.key.workspaceId),
});
if (!ws) {
this.logger.error("fallback workspace not found either", {
workspaceId: data.key.workspaceId,
});
return Err(new DisabledWorkspaceError(data.key.workspaceId));
}
data.workspace = ws;
}

if ((data.forWorkspace && !data.forWorkspace.enabled) || !data.workspace?.enabled) {
return Err(new DisabledWorkspaceError(data.workspace?.id ?? "N/A"));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/routes/v1_keys_verifyKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ export const registerV1KeysVerifyKey = (app: App) =>
code: val.valid ? ("VALID" as const) : val.code,
identity: val.identity
? {
id: val.identity.id,
externalId: val.identity.externalId,
meta: val.identity.meta ?? {},
}
id: val.identity.id,
externalId: val.identity.externalId,
meta: val.identity.meta ?? {},
}
: undefined,
};
c.executionCtx.waitUntil(
Expand Down
2 changes: 2 additions & 0 deletions oss.gg/4_starry_eyed_supporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Get five friends to star our repository.

Your GitHub account and the accounts of your friends must be older than one year. Do not create accounts for this sidequest!

**Points**: 150 Points

**Proof**: Open a PR with sufficient screenshots to prove that you asked them and they confirmed + their GitHub names.
Expand Down

0 comments on commit b7e8985

Please sign in to comment.