Skip to content

Commit d77f2bd

Browse files
Even more logging
1 parent 8cefa1b commit d77f2bd

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

chat-ui-quince/src/google.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ declare global {
2424
}
2525
}
2626

27-
28-
2927
async function handleGoogleSignIn(response: { credential: string }): Promise<void> {
30-
console.log('Callback triggered! Response:', response);
28+
console.log('Callback triggered! Response:', response); // Must appear
3129
const idToken = response.credential;
3230
if (!idToken) {
3331
console.error("No credential in GIS response:", response);
@@ -42,18 +40,18 @@ async function handleGoogleSignIn(response: { credential: string }): Promise<voi
4240
body: JSON.stringify(request),
4341
});
4442
if (!fetchResponse.ok) {
45-
const errorText = await fetchResponse.text(); // Get response body
43+
const errorText = await fetchResponse.text();
4644
console.error('Fetch failed:', fetchResponse.status, errorText);
47-
throw new Error(`HTTP error! # status: ${fetchResponse.status}`);
45+
throw new Error(`HTTP error! status: ${fetchResponse.status}`);
4846
}
4947
const data: VerifyResponse = await fetchResponse.json();
5048
console.log('User verified:', data);
5149
} catch (error) {
5250
console.error('Sign-in failed:', error);
5351
}
5452
}
55-
56-
window.addEventListener('load', () => {
53+
54+
window.addEventListener('load', () => {
5755
console.log('Window loaded, checking google.accounts.id:', window.google.accounts.id);
5856
if (!window.google || !window.google.accounts || !window.google.accounts.id) {
5957
console.error('Google Identity Services script not loaded');
@@ -65,12 +63,24 @@ window.addEventListener('load', () => {
6563
callback: handleGoogleSignIn
6664
});
6765
console.log('After initialize, google.accounts.id:', window.google.accounts.id);
68-
66+
6967
const loginBtn = document.getElementById('google-sign-in') as HTMLButtonElement;
68+
if (!loginBtn) {
69+
console.error('Login button not found');
70+
return;
71+
}
7072
loginBtn.onclick = function() {
71-
console.log('Before calling signIn, google.accounts.id:', window.google.accounts.id);
72-
//console.log('Calling signIn:', window.google.accounts.id.signIn);
73+
console.log('Button clicked, triggering prompt');
7374
console.log('Calling prompt:', window.google.accounts.id.prompt);
74-
window.google.accounts.id.prompt();
75+
window.google.accounts.id.prompt((notification) => {
76+
console.log('Prompt notification:', notification);
77+
if (notification.isNotDisplayed()) {
78+
console.log('Prompt not displayed:', notification.getNotDisplayedReason());
79+
} else if (notification.isSkippedMoment()) {
80+
console.log('Prompt skipped:', notification.getSkippedReason());
81+
} else if (notification.isDismissedMoment()) {
82+
console.log('Prompt dismissed:', notification.getDismissedReason());
83+
}
84+
});
7585
};
7686
});

0 commit comments

Comments
 (0)