Skip to content

Commit feb1ddc

Browse files
committed
connectiosn might be undefined
1 parent 21319db commit feb1ddc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/auth.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ import {Logger} from 'winston';
1212
import {UserData} from './service/user-data';
1313

1414
export async function discordUserCallback(steamClient: SteamClient, accessToken: string, refreshToken: string, profile: Profile, logger: Logger) {
15-
const steamConnection: ConnectionInfo | undefined = profile.connections.find((c) => c.type === 'steam');
16-
const xBoxConnection: ConnectionInfo | undefined = profile.connections.find((c) => c.type === 'xbox');
17-
const playStationConnection: ConnectionInfo | undefined = profile.connections.find((c) => c.type === 'playstation');
15+
let steamConnection: ConnectionInfo | undefined;
16+
let xBoxConnection: ConnectionInfo | undefined;
17+
let playStationConnection: ConnectionInfo | undefined;
18+
19+
if (profile.connections) {
20+
steamConnection = profile.connections.find((c) => c.type === 'steam');
21+
xBoxConnection = profile.connections.find((c) => c.type === 'xbox');
22+
playStationConnection = profile.connections.find((c) => c.type === 'playstation');
23+
}
1824
const user: User = {
1925
username: profile.username,
2026
discord: {
@@ -126,7 +132,10 @@ export class Authentication {
126132
});
127133
});
128134
}));
129-
this.router.get('/auth/discord/redirect', passport.authenticate('discord', {keepSessionInfo: true, prompt: 'none'}));
135+
this.router.get('/auth/discord/redirect', passport.authenticate('discord', {
136+
keepSessionInfo: true,
137+
prompt: 'none'
138+
}));
130139
this.router.get('/auth/discord/callback', passport.authenticate('discord', {
131140
failureRedirect: '/auth/error',
132141
keepSessionInfo: true

0 commit comments

Comments
 (0)