@@ -12,9 +12,15 @@ import {Logger} from 'winston';
1212import { UserData } from './service/user-data' ;
1313
1414export 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