|
199 | 199 | .then((resp) => { |
200 | 200 | // Email address has been verified. |
201 | 201 |
|
202 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-check"></i>`); |
| 202 | + qs("main .preloader .icon")?.setHtml( |
| 203 | + `<i class="fas fa-fw fa-check"></i>`, |
| 204 | + ); |
203 | 205 | qs("main .preloader .text")?.setText( |
204 | 206 | `Your email address has been verified`, |
205 | 207 | ); |
206 | 208 | qs("main .preloader .subText")?.setText(`You can now close this tab`); |
207 | 209 | }) |
208 | 210 | .catch((error) => { |
209 | 211 | console.error(error); |
210 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-times"></i>`); |
| 212 | + qs("main .preloader .icon")?.setHtml( |
| 213 | + `<i class="fas fa-fw fa-times"></i>`, |
| 214 | + ); |
211 | 215 | qs("main .preloader .text")?.setText( |
212 | 216 | `Fatal error: ${error.message}. If this issue persists, please report it.`, |
213 | 217 | ); |
|
234 | 238 | .then((email) => { |
235 | 239 | var accountEmail = email; |
236 | 240 |
|
237 | | - var newPassword = qs<HTMLInputElement>("main .resetPassword .pwd")?.getValue(); |
238 | | - var newPasswordConfirm = qs<HTMLInputElement>("main .resetPassword .pwd-confirm")?.getValue(); |
| 241 | + var newPassword = |
| 242 | + qs < HTMLInputElement > "main .resetPassword .pwd"?.getValue(); |
| 243 | + var newPasswordConfirm = |
| 244 | + qs < |
| 245 | + HTMLInputElement > |
| 246 | + "main .resetPassword .pwd-confirm"?.getValue(); |
239 | 247 |
|
240 | 248 | if (newPassword !== newPasswordConfirm) { |
241 | 249 | alert("Passwords do not match"); |
|
258 | 266 | qs("main .preloader .icon")?.setHtml( |
259 | 267 | `<i class="fas fa-fw fa-check"></i>`, |
260 | 268 | ); |
261 | | - qs("main .preloader .text")?.setText(`Your password has been changed`); |
262 | | - qs("main .preloader .subText")?.setText(`You can now close this tab`); |
| 269 | + qs("main .preloader .text")?.setText( |
| 270 | + `Your password has been changed`, |
| 271 | + ); |
| 272 | + qs("main .preloader .subText")?.setText( |
| 273 | + `You can now close this tab`, |
| 274 | + ); |
263 | 275 |
|
264 | 276 | signInWithEmailAndPassword(Auth, accountEmail, newPassword); |
265 | 277 | }) |
|
277 | 289 | }) |
278 | 290 | .catch((error) => { |
279 | 291 | console.error(error); |
280 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-times"></i>`); |
| 292 | + qs("main .preloader .icon")?.setHtml( |
| 293 | + `<i class="fas fa-fw fa-times"></i>`, |
| 294 | + ); |
281 | 295 | qs("main .preloader .text")?.setText( |
282 | 296 | `Fatal error: ${error.message}. If this issue persists, please report it.`, |
283 | 297 | ); |
|
303 | 317 | return applyActionCode(Auth, actionCode); |
304 | 318 | }) |
305 | 319 | .then(() => { |
306 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-check"></i>`); |
307 | | - qs("main .preloader .text")?.setText(`Your account email was reverted.`); |
| 320 | + qs("main .preloader .icon")?.setHtml( |
| 321 | + `<i class="fas fa-fw fa-check"></i>`, |
| 322 | + ); |
| 323 | + qs("main .preloader .text")?.setText( |
| 324 | + `Your account email was reverted.`, |
| 325 | + ); |
308 | 326 | qs("main .preloader .subText")?.setText(``); |
309 | 327 |
|
310 | 328 | qs("main .preloader")?.appendHtml(` |
|
325 | 343 | }) |
326 | 344 | .catch((error) => { |
327 | 345 | console.error(error); |
328 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-times"></i>`); |
| 346 | + qs("main .preloader .icon")?.setHtml( |
| 347 | + `<i class="fas fa-fw fa-times"></i>`, |
| 348 | + ); |
329 | 349 | qs("main .preloader .text")?.setText(error.message); |
330 | 350 | }); |
331 | 351 | } |
332 | 352 |
|
333 | 353 | function sendPasswordReset(email) { |
334 | 354 | sendPasswordResetEmail(Auth, email) |
335 | 355 | .then(() => { |
336 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-check"></i>`); |
| 356 | + qs("main .preloader .icon")?.setHtml( |
| 357 | + `<i class="fas fa-fw fa-check"></i>`, |
| 358 | + ); |
337 | 359 | qs("main .preloader .text")?.setText(`Password reset email sent`); |
338 | 360 | qs("main .preloader .subText")?.setText(`Please check your inbox`); |
339 | 361 | }) |
340 | 362 | .catch((error) => { |
341 | 363 | console.error(error); |
342 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-times"></i>`); |
| 364 | + qs("main .preloader .icon")?.setHtml( |
| 365 | + `<i class="fas fa-fw fa-times"></i>`, |
| 366 | + ); |
343 | 367 | qs("main .preloader .text")?.setText(error.message); |
344 | 368 | }); |
345 | 369 | } |
|
354 | 378 | } |
355 | 379 |
|
356 | 380 | onDOMReady(() => { |
357 | | - try { |
358 | | - // Get the action to complete. |
359 | | - var mode = getParameterByName("mode"); |
360 | | - // Get the one-time code from the query parameter. |
361 | | - var actionCode = getParameterByName("oobCode"); |
362 | | - // (Optional) Get the continue URL from the query parameter if available. |
363 | | - var continueUrl = getParameterByName("continueUrl"); |
364 | | - // (Optional) Get the language code if available. |
365 | | - var lang = getParameterByName("lang") || "en"; |
366 | | - |
367 | | - // Configure the Firebase SDK. |
368 | | - // // This is the minimum configuration required for the API to be used. |
369 | | - // var config = { |
370 | | - // 'apiKey': "YOU_API_KEY" // Copy this key from the web initialization |
371 | | - // // snippet found in the Firebase console. |
372 | | - // }; |
373 | | - // var app = firebase.initializeApp(config); |
374 | | - // var auth = firebase.auth(); |
375 | | - |
376 | | - if (!mode) { |
377 | | - qs("main .preloader .icon")?.setHtml( |
378 | | - `<i class="fas fa-fw fa-times"></i>`, |
379 | | - ); |
380 | | - qs("main .preloader .text")?.setText(`Mode parameter not found`); |
381 | | - return; |
382 | | - } |
| 381 | + try { |
| 382 | + // Get the action to complete. |
| 383 | + var mode = getParameterByName("mode"); |
| 384 | + // Get the one-time code from the query parameter. |
| 385 | + var actionCode = getParameterByName("oobCode"); |
| 386 | + // (Optional) Get the continue URL from the query parameter if available. |
| 387 | + var continueUrl = getParameterByName("continueUrl"); |
| 388 | + // (Optional) Get the language code if available. |
| 389 | + var lang = getParameterByName("lang") || "en"; |
| 390 | + |
| 391 | + // Configure the Firebase SDK. |
| 392 | + // // This is the minimum configuration required for the API to be used. |
| 393 | + // var config = { |
| 394 | + // 'apiKey': "YOU_API_KEY" // Copy this key from the web initialization |
| 395 | + // // snippet found in the Firebase console. |
| 396 | + // }; |
| 397 | + // var app = firebase.initializeApp(config); |
| 398 | + // var auth = firebase.auth(); |
| 399 | + |
| 400 | + if (!mode) { |
| 401 | + qs("main .preloader .icon")?.setHtml( |
| 402 | + `<i class="fas fa-fw fa-times"></i>`, |
| 403 | + ); |
| 404 | + qs("main .preloader .text")?.setText(`Mode parameter not found`); |
| 405 | + return; |
| 406 | + } |
| 407 | + |
| 408 | + if (!actionCode) { |
| 409 | + qs("main .preloader .icon")?.setHtml( |
| 410 | + `<i class="fas fa-fw fa-times"></i>`, |
| 411 | + ); |
| 412 | + qs("main .preloader .text")?.setText( |
| 413 | + `Action code parameter not found`, |
| 414 | + ); |
| 415 | + return; |
| 416 | + } |
383 | 417 |
|
384 | | - if (!actionCode) { |
| 418 | + // Handle the user management action. |
| 419 | + switch (mode) { |
| 420 | + case "resetPassword": |
| 421 | + // Display reset password handler and UI. |
| 422 | + qs("#logo .text span")?.setText("Reset Password"); |
| 423 | + document.title = "Reset Password | Monkeytype"; |
| 424 | + showResetPassword(); |
| 425 | + break; |
| 426 | + case "recoverEmail": |
| 427 | + // Display email recovery handler and UI. |
| 428 | + handleRecoverEmail(actionCode); |
| 429 | + break; |
| 430 | + case "verifyEmail": |
| 431 | + qs("#logo .text span")?.setText("Verify Email"); |
| 432 | + document.title = "Verify Email | Monkeytype"; |
| 433 | + // Display email verification handler and UI. |
| 434 | + handleVerifyEmail(actionCode, continueUrl); |
| 435 | + break; |
| 436 | + default: |
385 | 437 | qs("main .preloader .icon")?.setHtml( |
386 | 438 | `<i class="fas fa-fw fa-times"></i>`, |
387 | 439 | ); |
388 | | - qs("main .preloader .text")?.setText(`Action code parameter not found`); |
389 | | - return; |
390 | | - } |
391 | | - |
392 | | - // Handle the user management action. |
393 | | - switch (mode) { |
394 | | - case "resetPassword": |
395 | | - // Display reset password handler and UI. |
396 | | - qs("#logo .text span")?.setText("Reset Password"); |
397 | | - document.title = "Reset Password | Monkeytype"; |
398 | | - showResetPassword(); |
399 | | - break; |
400 | | - case "recoverEmail": |
401 | | - // Display email recovery handler and UI. |
402 | | - handleRecoverEmail(actionCode); |
403 | | - break; |
404 | | - case "verifyEmail": |
405 | | - qs("#logo .text span")?.setText("Verify Email"); |
406 | | - document.title = "Verify Email | Monkeytype"; |
407 | | - // Display email verification handler and UI. |
408 | | - handleVerifyEmail(actionCode, continueUrl); |
409 | | - break; |
410 | | - default: |
411 | | - qs("main .preloader .icon")?.setHtml( |
412 | | - `<i class="fas fa-fw fa-times"></i>`, |
413 | | - ); |
414 | | - qs("main .preloader .text")?.setText(`Invalid mode`); |
415 | | - console.error("no mode found"); |
416 | | - // Error: invalid mode. |
417 | | - } |
| 440 | + qs("main .preloader .text")?.setText(`Invalid mode`); |
| 441 | + console.error("no mode found"); |
| 442 | + // Error: invalid mode. |
| 443 | + } |
418 | 444 |
|
419 | | - qs("main .resetPassword .button")?.on("click", () => { |
420 | | - handleResetPassword(actionCode, continueUrl); |
421 | | - }); |
| 445 | + qs("main .resetPassword .button")?.on("click", () => { |
| 446 | + handleResetPassword(actionCode, continueUrl); |
| 447 | + }); |
422 | 448 |
|
423 | | - qs("main .resetPassword input")?.on("keypress", (e) => { |
424 | | - if (e.key === "Enter") handleResetPassword(actionCode, continueUrl); |
425 | | - }); |
426 | | - } catch (e) { |
427 | | - qs("main .preloader .icon")?.setHtml(`<i class="fas fa-fw fa-times"></i>`); |
428 | | - qs("main .preloader .text")?.setText( |
429 | | - `Fatal error: ${e.message}. If this issue persists, please report it.`, |
430 | | - ); |
431 | | - } |
432 | | - }); |
| 449 | + qs("main .resetPassword input")?.on("keypress", (e) => { |
| 450 | + if (e.key === "Enter") handleResetPassword(actionCode, continueUrl); |
| 451 | + }); |
| 452 | + } catch (e) { |
| 453 | + qs("main .preloader .icon")?.setHtml( |
| 454 | + `<i class="fas fa-fw fa-times"></i>`, |
| 455 | + ); |
| 456 | + qs("main .preloader .text")?.setText( |
| 457 | + `Fatal error: ${e.message}. If this issue persists, please report it.`, |
| 458 | + ); |
| 459 | + } |
| 460 | + }); |
433 | 461 |
|
434 | 462 | qs("header")?.on("click", () => { |
435 | 463 | window.location = "/"; |
|
0 commit comments