Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions apps/web/src/trpc/commands/github/mutations.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 30 additions & 3 deletions apps/web/src/trpc/commands/github/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,26 @@ async function getGitHubOAuthUser({
}
| { success: false; error: string }
> {
const [clientId, clientSecret] = await Promise.all([
resolveDeploymentEnvVar('GITHUB_CLIENT_ID'),
resolveDeploymentEnvVar('GITHUB_CLIENT_SECRET'),
]);

if (!clientId || !clientSecret) {
console.error(
`[${context}] GitHub App OAuth credentials are not configured.`,
);

return {
success: false,
error:
'GitHub App OAuth credentials are not configured for this deployment.',
};
}

const params = new URLSearchParams({
client_id: Env.GITHUB_CLIENT_ID,
client_secret: Env.GITHUB_CLIENT_SECRET,
client_id: clientId,
client_secret: clientSecret,
code,
});

Expand Down Expand Up @@ -778,9 +795,19 @@ export async function startAuthenticateGitHubAccountCommand(
state?: Record<string, string>,
): Promise<{ success: true; url: string } | { success: false; error: string }> {
try {
const clientId = await resolveDeploymentEnvVar('GITHUB_CLIENT_ID');

if (!clientId) {
return {
success: false,
error:
'Configure a GitHub App for this deployment before linking your GitHub account. Create one or enter its credentials first.',
};
}

const baseUrl = Env.ROOMOTE_APP_URL;
const params = new URLSearchParams({
client_id: Env.GITHUB_CLIENT_ID,
client_id: clientId,
scope: 'read:user',
state: encodeRecord({ ...(state ?? {}), mode: 'auth' }),
});
Expand Down