Skip to content

Commit f63e800

Browse files
committed
fix: Simplify reply handling in auth routes for consistent return statements
1 parent 701cab8 commit f63e800

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

server/routes/auth-mcp.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ async function authPlugin(fastify) {
2020
mcpIssuerConfiguration.authorizationEndpoint,
2121
);
2222

23-
reply.redirect(redirectUri);
24-
25-
return reply;
23+
return reply.redirect(redirectUri);
2624
});
2725

2826
fastify.get('/auth/mcp/callback', async (req, reply) => {
@@ -45,7 +43,7 @@ async function authPlugin(fastify) {
4543
req.encryptedSession.delete('mcp_tokenExpiresAt');
4644
}
4745

48-
reply.redirect(POST_LOGIN_REDIRECT + callbackResult.postLoginRedirectRoute);
46+
return reply.redirect(POST_LOGIN_REDIRECT + callbackResult.postLoginRedirectRoute);
4947
} catch (error) {
5048
if (error instanceof AuthenticationError) {
5149
req.log.error('AuthenticationError during OIDC callback: %s', error);
@@ -54,8 +52,6 @@ async function authPlugin(fastify) {
5452
throw error;
5553
}
5654
}
57-
58-
return reply;
5955
});
6056

6157
fastify.get('/auth/mcp/me', async (req, reply) => {

server/routes/auth-onboarding.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function authPlugin(fastify) {
4343
req.encryptedSession.delete('onboarding_tokenExpiresAt');
4444
}
4545

46-
reply.redirect(POST_LOGIN_REDIRECT + callbackResult.postLoginRedirectRoute);
46+
return reply.redirect(POST_LOGIN_REDIRECT + callbackResult.postLoginRedirectRoute);
4747
} catch (error) {
4848
if (error instanceof AuthenticationError) {
4949
req.log.error('AuthenticationError during OIDC callback: %s', error);
@@ -52,8 +52,6 @@ async function authPlugin(fastify) {
5252
throw error;
5353
}
5454
}
55-
56-
return reply;
5755
});
5856

5957
fastify.get('/auth/onboarding/me', async (req, reply) => {
@@ -62,17 +60,13 @@ async function authPlugin(fastify) {
6260

6361
const isAuthenticated = Boolean(accessToken);
6462
const user = isAuthenticated ? userInfo : null;
65-
reply.send({ isAuthenticated, user });
66-
67-
return reply;
63+
return reply.send({ isAuthenticated, user });
6864
});
6965

7066
fastify.post('/auth/logout', async (req, reply) => {
7167
// TODO: Idp sign out flow
7268
req.encryptedSession.clear();
73-
reply.send({ message: 'Logged out' });
74-
75-
return reply;
69+
return reply.send({ message: 'Logged out' });
7670
});
7771
}
7872

0 commit comments

Comments
 (0)