Update signing.html
Browse files- signing.html +19 -2
signing.html
CHANGED
|
@@ -137,6 +137,7 @@
|
|
| 137 |
// ---------- Handle redirect result (page load after signInWithRedirect) ----------
|
| 138 |
getRedirectResult(auth)
|
| 139 |
.then(async (result) => {
|
|
|
|
| 140 |
if (result && result.user) {
|
| 141 |
// Successful redirect result
|
| 142 |
const user = result.user;
|
|
@@ -180,13 +181,29 @@
|
|
| 180 |
// Use redirect flow in environments where popup is unreliable
|
| 181 |
console.log('Detected webview/in-app: using signInWithRedirect.');
|
| 182 |
// signInWithRedirect will redirect the browser away; getRedirectResult will handle the result on return.
|
| 183 |
-
await signInWithRedirect(auth, provider)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
// After this line the browser navigates away; no further code executes in most cases.
|
| 185 |
} else {
|
| 186 |
// Desktop / normal browsers: popup flow
|
| 187 |
console.log('Using signInWithPopup for desktop browser.');
|
| 188 |
const result = await signInWithPopup(auth, provider);
|
| 189 |
-
|
| 190 |
|
| 191 |
if (result && result.user) {
|
| 192 |
const user = result.user;
|
|
|
|
| 137 |
// ---------- Handle redirect result (page load after signInWithRedirect) ----------
|
| 138 |
getRedirectResult(auth)
|
| 139 |
.then(async (result) => {
|
| 140 |
+
alert("rere", result);
|
| 141 |
if (result && result.user) {
|
| 142 |
// Successful redirect result
|
| 143 |
const user = result.user;
|
|
|
|
| 181 |
// Use redirect flow in environments where popup is unreliable
|
| 182 |
console.log('Detected webview/in-app: using signInWithRedirect.');
|
| 183 |
// signInWithRedirect will redirect the browser away; getRedirectResult will handle the result on return.
|
| 184 |
+
await signInWithRedirect(auth, provider).then(async (result) => {
|
| 185 |
+
alert("rere", result);
|
| 186 |
+
if (result && result.user) {
|
| 187 |
+
// Successful redirect result
|
| 188 |
+
const user = result.user;
|
| 189 |
+
try {
|
| 190 |
+
const token = await user.getIdToken();
|
| 191 |
+
showSuccess(user);
|
| 192 |
+
// small delay to let user see success message
|
| 193 |
+
setTimeout(() => redirectToApp(token, user), 1000);
|
| 194 |
+
} catch (tokenErr) {
|
| 195 |
+
console.error('Token error after redirect:', tokenErr);
|
| 196 |
+
safeSetError('Signed in but failed to retrieve token. See console for details.');
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
|
| 201 |
// After this line the browser navigates away; no further code executes in most cases.
|
| 202 |
} else {
|
| 203 |
// Desktop / normal browsers: popup flow
|
| 204 |
console.log('Using signInWithPopup for desktop browser.');
|
| 205 |
const result = await signInWithPopup(auth, provider);
|
| 206 |
+
|
| 207 |
|
| 208 |
if (result && result.user) {
|
| 209 |
const user = result.user;
|