Skip to content

Commit 3495aba

Browse files
committed
fixup working examples
1 parent b3c565a commit 3495aba

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/examples/server/demoInMemoryOAuthProvider.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,20 @@ export class DemoInMemoryAuthProvider implements OAuthServerProvider {
5959

6060
// Simulate a user login
6161
// Set a secure HTTP-only session cookie with authorization info
62-
const authCookieData = {
63-
userId: 'demo_user',
64-
name: 'Demo User',
65-
timestamp: Date.now()
66-
};
67-
res.cookie('demo_session', JSON.stringify(authCookieData), {
68-
httpOnly: true,
69-
secure: false, // In production, this should be true
70-
sameSite: 'lax',
71-
maxAge: 24 * 60 * 60 * 1000, // 24 hours - for demo purposes
72-
path: '/' // Available to all routes
73-
});
62+
if (res.cookie) {
63+
const authCookieData = {
64+
userId: 'demo_user',
65+
name: 'Demo User',
66+
timestamp: Date.now()
67+
};
68+
res.cookie('demo_session', JSON.stringify(authCookieData), {
69+
httpOnly: true,
70+
secure: false, // In production, this should be true
71+
sameSite: 'lax',
72+
maxAge: 24 * 60 * 60 * 1000, // 24 hours - for demo purposes
73+
path: '/' // Available to all routes
74+
});
75+
}
7476

7577
if (!client.redirect_uris.includes(params.redirectUri)) {
7678
throw new InvalidRequestError('Unregistered redirect_uri');

0 commit comments

Comments
 (0)