Skip to content

Commit f414719

Browse files
fix(connect): add missing randomBytes import and rename parseGoogleState (#211)
randomBytes was used in generateState() without being imported from crypto, causing a ReferenceError crash on any GET /connect/github request. Also renamed parseGoogleState to parseOAuthState since the function is exclusively used in the GitHub connect flow — Google connect does not exist in this file. Closes #178 Signed-off-by: Prashantkumar Khatri <96608160+ShantKhatri@users.noreply.github.com> Co-authored-by: Prashantkumar Khatri <96608160+ShantKhatri@users.noreply.github.com>
1 parent da4d4e2 commit f414719

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

apps/backend/src/routes/connect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function connectRoutes(app: FastifyInstance) {
6363

6464
try {
6565
// Decode state to find which user requested the connect
66-
const decodedState = parseGoogleState(state);
66+
const decodedState = parseOAuthState(state);
6767

6868
if (!decodedState) {
6969
return reply.redirect(`${process.env.PUBLIC_APP_URL}/settings?error=connect_failed`);
@@ -158,7 +158,7 @@ export async function connectRoutes(app: FastifyInstance) {
158158
});
159159
}
160160

161-
function parseGoogleState(state: string): ParsedOAuthState | null {
161+
function parseOAuthState(state: string): ParsedOAuthState | null {
162162
try {
163163
const decoded = JSON.parse(Buffer.from(state, 'base64').toString('utf-8'));
164164

0 commit comments

Comments
 (0)