Skip to content

Commit afd64bb

Browse files
committed
fix: session is now available again
1 parent edca080 commit afd64bb

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

server.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,11 @@ const isDev = process.argv.includes('--dev');
1212

1313
const __filename = fileURLToPath(import.meta.url);
1414
const __dirname = path.dirname(__filename);
15-
const frontendConfigLocation = isDev
16-
? 'public/frontend-config.json'
17-
: 'dist/client/frontend-config.json';
18-
19-
if (
20-
process.env.FRONTEND_CONFIG_PATH !== undefined &&
21-
process.env.FRONTEND_CONFIG_PATH.length > 0
22-
) {
23-
console.log(
24-
'FRONTEND_CONFIG_PATH is specified. Will copy the frontend-config from there.',
25-
);
26-
console.log(
27-
` Copying ${process.env.FRONTEND_CONFIG_PATH} to ${frontendConfigLocation}`,
28-
);
15+
const frontendConfigLocation = isDev ? 'public/frontend-config.json' : 'dist/client/frontend-config.json';
16+
17+
if (process.env.FRONTEND_CONFIG_PATH !== undefined && process.env.FRONTEND_CONFIG_PATH.length > 0) {
18+
console.log('FRONTEND_CONFIG_PATH is specified. Will copy the frontend-config from there.');
19+
console.log(` Copying ${process.env.FRONTEND_CONFIG_PATH} to ${frontendConfigLocation}`);
2920
copyFileSync(process.env.FRONTEND_CONFIG_PATH, frontendConfigLocation);
3021
}
3122

@@ -43,7 +34,7 @@ await fastify.register(FastifyVite, {
4334
spa: true,
4435
});
4536

46-
fastify.get('/', (req, reply) => {
37+
fastify.get('/', function (req, reply) {
4738
return reply.html();
4839
});
4940

server/routes/auth-mcp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function authPlugin(fastify) {
99
const mcpIssuerConfiguration = await fastify.discoverIssuerConfiguration(OIDC_ISSUER);
1010
fastify.decorate('mcpIssuerConfiguration', mcpIssuerConfiguration);
1111

12-
fastify.get('/auth/mcp/login', async (req, reply) => {
12+
fastify.get('/auth/mcp/login', async function (req, reply) {
1313
const redirectUri = fastify.prepareOidcLoginRedirect(
1414
req,
1515
{
@@ -23,7 +23,7 @@ async function authPlugin(fastify) {
2323
return reply.redirect(redirectUri);
2424
});
2525

26-
fastify.get('/auth/mcp/callback', async (req, reply) => {
26+
fastify.get('/auth/mcp/callback', async function (req, reply) {
2727
try {
2828
const callbackResult = await fastify.handleOidcCallback(
2929
req,
@@ -54,11 +54,11 @@ async function authPlugin(fastify) {
5454
}
5555
});
5656

57-
fastify.get('/auth/mcp/me', async (req, reply) => {
57+
fastify.get('/auth/mcp/me', async function (req, reply) {
5858
const accessToken = req.encryptedSession.get('mcp_accessToken');
5959

6060
const isAuthenticated = Boolean(accessToken);
61-
return reply.send({ isAuthenticated });
61+
reply.send({ isAuthenticated });
6262
});
6363
}
6464

server/routes/auth-onboarding.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function authPlugin(fastify) {
88
const issuerConfiguration = await fastify.discoverIssuerConfiguration(OIDC_ISSUER);
99
fastify.decorate('issuerConfiguration', issuerConfiguration);
1010

11-
fastify.get('/auth/onboarding/login', async (req, reply) => {
11+
fastify.get('/auth/onboarding/login', async function (req, reply) {
1212
const redirectUri = fastify.prepareOidcLoginRedirect(
1313
req,
1414
{
@@ -22,7 +22,7 @@ async function authPlugin(fastify) {
2222
return reply.redirect(redirectUri);
2323
});
2424

25-
fastify.get('/auth/onboarding/callback', async (req, reply) => {
25+
fastify.get('/auth/onboarding/callback', async function (req, reply) {
2626
try {
2727
const callbackResult = await fastify.handleOidcCallback(
2828
req,
@@ -54,19 +54,20 @@ async function authPlugin(fastify) {
5454
}
5555
});
5656

57-
fastify.get('/auth/onboarding/me', async (req, reply) => {
57+
fastify.get('/auth/onboarding/me', async function (req, reply) {
5858
const accessToken = req.encryptedSession.get('onboarding_accessToken');
5959
const userInfo = req.encryptedSession.get('onboarding_userInfo');
6060

6161
const isAuthenticated = Boolean(accessToken);
6262
const user = isAuthenticated ? userInfo : null;
63-
return reply.send({ isAuthenticated, user });
63+
64+
reply.send({ isAuthenticated, user });
6465
});
6566

66-
fastify.post('/auth/logout', async (req, reply) => {
67+
fastify.post('/auth/logout', async function (req, reply) {
6768
// TODO: Idp sign out flow
6869
req.encryptedSession.clear();
69-
return reply.send({ message: 'Logged out' });
70+
reply.send({ message: 'Logged out' });
7071
});
7172
}
7273

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"noFallthroughCasesInSwitch": true,
2020
"types": ["node", "cypress"]
2121
},
22-
"include": ["src", "cypress.d.ts", "server.js", "i18n.ts"],
22+
"include": ["src", "cypress.d.ts", "server.js", "i18n.ts", "server/**/*"],
2323
"references": [
2424
{
2525
"path": "./tsconfig.node.json"

0 commit comments

Comments
 (0)