@@ -98,10 +98,26 @@ async function handleGoogleLogin(req: Request, _accessToken: string, _refreshTok
9898 * Passport strategy for authenticate with google
9999 * http://www.passportjs.org/packages/passport-google-oauth20/
100100 */
101- export default new GoogleStrategy . Strategy ( {
102- clientID : process . env . GOOGLE_CLIENT_ID as string ,
103- clientSecret : process . env . GOOGLE_CLIENT_SECRET as string ,
104- callbackURL : process . env . GOOGLE_CALLBACK_URL as string ,
105- passReqToCallback : true
106- } ,
107- ( req , _accessToken , _refreshToken , profile , done ) => void handleGoogleLogin ( req , _accessToken , _refreshToken , profile , done ) ) ;
101+ const googleClientId = process . env . GOOGLE_CLIENT_ID ;
102+ const googleClientSecret = process . env . GOOGLE_CLIENT_SECRET ;
103+ const googleCallbackUrl = process . env . GOOGLE_CALLBACK_URL ;
104+
105+ const GoogleLogin =
106+ googleClientId &&
107+ googleClientId !== "disabled" &&
108+ googleClientSecret &&
109+ googleClientSecret !== "disabled" &&
110+ googleCallbackUrl
111+ ? new GoogleStrategy . Strategy (
112+ {
113+ clientID : googleClientId ,
114+ clientSecret : googleClientSecret ,
115+ callbackURL : googleCallbackUrl ,
116+ passReqToCallback : true
117+ } ,
118+ ( req , _accessToken , _refreshToken , profile , done ) =>
119+ void handleGoogleLogin ( req , _accessToken , _refreshToken , profile , done )
120+ )
121+ : null ;
122+
123+ export default GoogleLogin ;
0 commit comments