Skip to content

Commit d5d44f4

Browse files
committed
Return early if google is undefined.
1 parent 4959257 commit d5d44f4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

assets/js/sign-in-with-google.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ export async function handleCredentialResponse(
9595
}
9696

9797
export function setupSignInWithGoogle( data: SignInWithGoogleData ) {
98-
google?.accounts.id.initialize( {
98+
if ( typeof google?.accounts?.id === 'undefined' ) {
99+
return;
100+
}
101+
102+
google.accounts.id.initialize( {
99103
client_id: data.clientID, // eslint-disable-line camelcase
100104
callback: ( response ) => handleCredentialResponse( response, data ),
101105
library_name: 'Site-Kit', // eslint-disable-line camelcase
@@ -145,7 +149,7 @@ export function setupSignInWithGoogle( data: SignInWithGoogleData ) {
145149
}
146150

147151
if ( data.shouldShowOneTapPrompt ) {
148-
google?.accounts.id.prompt();
152+
google.accounts.id.prompt();
149153
}
150154

151155
if ( data.redirectTo ) {

0 commit comments

Comments
 (0)