monkeytype/static/email-handler.html
2022-01-04 17:12:42 +01:00

377 lines
16 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Email Handler | Monkeytype</title>
<!-- <link rel="stylesheet" href="css/fa.css" /> -->
<link rel="stylesheet" href="css/balloon.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="themes/serika_dark.css" id="currentTheme" />
<link rel="stylesheet" href="" id="funBoxTheme" />
<link id="favicon" rel="shortcut icon" href="images/fav.png" />
<link rel="shortcut icon" href="images/fav.png" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<meta name="name" content="Monkeytype" />
<meta name="image" content="https://monkeytype.com/mtsocial.png" />
<meta
name="description"
content="A minimalistic, customisable typing website. Test yourself in various modes, track your progress and improve your typing speed."
/>
<meta
name="keywords"
content="typing, test, typing-test, typing test, monkey-type, monkeytype, monkey type, monkey-types, monkeytypes, monkey types, types, monkey, type, miodec, wpm, words per minute, typing website, minimalistic, custom typing test, customizable, customisable, themes, random words, smooth caret, smooth, new, new typing site, new typing website, minimalist typing website, minimalistic typing website, minimalist typing test"
/>
<meta name="author" content="Miodec" />
<meta property="og:title" content="Monkeytype" />
<meta property="og:url" content="https://monkeytype.com/" />
<meta property="og:type" content="website" />
<meta
property="og:description"
content="A minimalistic, customisable typing website. Test yourself in various modes, track your progress and improve your typing speed."
/>
<meta property="og:image" content="https://monkeytype.com/mtsocial.png" />
<meta name="theme-color" content="#e2b714" id="metaThemeColor" />
<meta name="twitter:title" content="Monkeytype" />
<meta name="twitter:image" content="https://monkeytype.com/mtsocial.png" />
<meta name="twitter:card" content="summary_large_image" />
<style>
#top {
font-size: 2.5rem;
}
#middle {
color: var(--text-color);
display: grid;
justify-content: center;
}
h1 {
font-weight: unset;
color: var(--main-color);
font-size: 2rem;
margin-top: 3rem;
}
body {
justify-content: center;
display: flex;
}
.preloader {
text-align: center;
display: grid;
width: 300px;
/* gap: 1rem; */
}
.preloader .icon {
font-size: 2rem;
color: var(--main-color);
margin-bottom: 1rem;
}
.preloader .subText {
font-size: 1rem;
color: var(--sub-color);
font-style: italic;
}
.resetPassword {
display: grid;
width: 300px;
gap: 1rem;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div id="centerContent">
<div id="top">
<div class="logo">
<div class="icon">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
style="isolation: isolate"
viewBox="-680 -1030 300 180"
>
<g>
<path
d="M -430 -910 L -430 -910 C -424.481 -910 -420 -905.519 -420 -900 L -420 -900 C -420 -894.481 -424.481 -890 -430 -890 L -430 -890 C -435.519 -890 -440 -894.481 -440 -900 L -440 -900 C -440 -905.519 -435.519 -910 -430 -910 Z"
/>
<path
d=" M -570 -910 L -510 -910 C -504.481 -910 -500 -905.519 -500 -900 L -500 -900 C -500 -894.481 -504.481 -890 -510 -890 L -570 -890 C -575.519 -890 -580 -894.481 -580 -900 L -580 -900 C -580 -905.519 -575.519 -910 -570 -910 Z "
/>
<path
d="M -590 -970 L -590 -970 C -584.481 -970 -580 -965.519 -580 -960 L -580 -940 C -580 -934.481 -584.481 -930 -590 -930 L -590 -930 C -595.519 -930 -600 -934.481 -600 -940 L -600 -960 C -600 -965.519 -595.519 -970 -590 -970 Z"
/>
<path
d=" M -639.991 -960.515 C -639.72 -976.836 -626.385 -990 -610 -990 L -610 -990 C -602.32 -990 -595.31 -987.108 -590 -982.355 C -584.69 -987.108 -577.68 -990 -570 -990 L -570 -990 C -553.615 -990 -540.28 -976.836 -540.009 -960.515 C -540.001 -960.345 -540 -960.172 -540 -960 L -540 -960 L -540 -940 C -540 -934.481 -544.481 -930 -550 -930 L -550 -930 C -555.519 -930 -560 -934.481 -560 -940 L -560 -960 L -560 -960 C -560 -965.519 -564.481 -970 -570 -970 C -575.519 -970 -580 -965.519 -580 -960 L -580 -960 L -580 -960 L -580 -940 C -580 -934.481 -584.481 -930 -590 -930 L -590 -930 C -595.519 -930 -600 -934.481 -600 -940 L -600 -960 L -600 -960 L -600 -960 L -600 -960 L -600 -960 L -600 -960 L -600 -960 L -600 -960 C -600 -965.519 -604.481 -970 -610 -970 C -615.519 -970 -620 -965.519 -620 -960 L -620 -960 L -620 -940 C -620 -934.481 -624.481 -930 -630 -930 L -630 -930 C -635.519 -930 -640 -934.481 -640 -940 L -640 -960 L -640 -960 C -640 -960.172 -639.996 -960.344 -639.991 -960.515 Z "
/>
<path
d=" M -460 -930 L -460 -900 C -460 -894.481 -464.481 -890 -470 -890 L -470 -890 C -475.519 -890 -480 -894.481 -480 -900 L -480 -930 L -508.82 -930 C -514.99 -930 -520 -934.481 -520 -940 L -520 -940 C -520 -945.519 -514.99 -950 -508.82 -950 L -431.18 -950 C -425.01 -950 -420 -945.519 -420 -940 L -420 -940 C -420 -934.481 -425.01 -930 -431.18 -930 L -460 -930 Z "
/>
<path
d="M -470 -990 L -430 -990 C -424.481 -990 -420 -985.519 -420 -980 L -420 -980 C -420 -974.481 -424.481 -970 -430 -970 L -470 -970 C -475.519 -970 -480 -974.481 -480 -980 L -480 -980 C -480 -985.519 -475.519 -990 -470 -990 Z"
/>
<path
d=" M -630 -910 L -610 -910 C -604.481 -910 -600 -905.519 -600 -900 L -600 -900 C -600 -894.481 -604.481 -890 -610 -890 L -630 -890 C -635.519 -890 -640 -894.481 -640 -900 L -640 -900 C -640 -905.519 -635.519 -910 -630 -910 Z "
/>
<path
d=" M -515 -990 L -510 -990 C -504.481 -990 -500 -985.519 -500 -980 L -500 -980 C -500 -974.481 -504.481 -970 -510 -970 L -515 -970 C -520.519 -970 -525 -974.481 -525 -980 L -525 -980 C -525 -985.519 -520.519 -990 -515 -990 Z "
/>
<path
d=" M -660 -910 L -680 -910 L -680 -980 C -680 -1007.596 -657.596 -1030 -630 -1030 L -430 -1030 C -402.404 -1030 -380 -1007.596 -380 -980 L -380 -900 C -380 -872.404 -402.404 -850 -430 -850 L -630 -850 C -657.596 -850 -680 -872.404 -680 -900 L -680 -920 L -660 -920 L -660 -900 C -660 -883.443 -646.557 -870 -630 -870 L -430 -870 C -413.443 -870 -400 -883.443 -400 -900 L -400 -980 C -400 -996.557 -413.443 -1010 -430 -1010 L -630 -1010 C -646.557 -1010 -660 -996.557 -660 -980 L -660 -910 Z "
/>
</g>
</svg>
</div>
<div class="text">
<div class="top">monkey see</div>
monkeytype
<span style="color: var(--main-color)">Email Handler</span>
</div>
</div>
</div>
<div id="middle">
<div class="preloader">
<div class="icon">
<i class="fas fa-fw fa-spin fa-circle-notch"></i>
</div>
<div class="text"></div>
<div class="subText"></div>
</div>
<div class="resetPassword hidden">
<input type="password" placeholder="New password" />
<div class="button">Change</div>
</div>
</div>
</div>
<!-- TODO: Add image to go back to top of page -->
</body>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="/__/firebase/8.4.2/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="/__/firebase/8.4.2/firebase-analytics.js"></script>
<script src="/__/firebase/8.4.2/firebase-auth.js"></script>
<script src="/__/firebase/8.4.2/firebase-firestore.js"></script>
<script src="/__/firebase/8.4.2/firebase-functions.js"></script>
<!-- Initialize Firebase -->
<script src="/__/firebase/init.js?useEmulator=true'"></script>
<script defer>
function handleVerifyEmail(actionCode, continueUrl) {
firebase
.auth()
.applyActionCode(actionCode)
.then((resp) => {
// Email address has been verified.
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-check"></i>`
);
$("#middle .preloader .text").text(
`Your email address has been verified.`
);
$("#middle .preloader .subText").text(`You can now close this tab.`);
// TODO: Display a confirmation message to the user.
// You could also provide the user with a link back to the app.
// TODO: If a continue URL is available, display a button which on
// click redirects the user back to the app via continueUrl with
// additional state determined from that URL's parameters.
})
.catch((error) => {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(error.message);
// Code is invalid or expired. Ask the user to verify their email address
// again.
});
}
function showResetPassword() {
$("#middle .preloader").addClass("hidden");
$("#middle .resetPassword").removeClass("hidden");
$("#middle .resetPassword input").focus();
}
function hideResetPassword() {
$("#middle .preloader").removeClass("hidden");
$("#middle .resetPassword").addClass("hidden");
}
function handleResetPassword(actionCode, continueUrl) {
// Verify the password reset code is valid.
hideResetPassword();
firebase
.auth()
.verifyPasswordResetCode(actionCode)
.then((email) => {
var accountEmail = email;
// TODO: Show the reset screen with the user's email and ask the user for
// the new password.
var newPassword = $("#middle .resetPassword input").val();
// Save the new password.
firebase
.auth()
.confirmPasswordReset(actionCode, newPassword)
.then((resp) => {
// Password reset has been confirmed and new password updated.
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-check"></i>`
);
$("#middle .preloader .text").text(
`Your password has been changed.`
);
$("#middle .preloader .subText").text(
`You can now close this tab.`
);
// TODO: Display a link back to the app, or sign-in the user directly
// if the page belongs to the same domain as the app:
firebase
.auth()
.signInWithEmailAndPassword(accountEmail, newPassword);
// TODO: If a continue URL is available, display a button which on
// click redirects the user back to the app via continueUrl with
// additional state determined from that URL's parameters.
})
.catch((error) => {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(error.message);
// Error occurred during confirmation. The code might have expired or the
// password is too weak.
});
})
.catch((error) => {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(error.message);
// $("#middle .preloader .subText").text(error);
// Invalid or expired action code. Ask user to try to reset the password
// again.
});
}
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return "";
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
document.addEventListener(
"DOMContentLoaded",
() => {
try {
// Get the action to complete.
var mode = getParameterByName("mode");
// Get the one-time code from the query parameter.
var actionCode = getParameterByName("oobCode");
// (Optional) Get the continue URL from the query parameter if available.
var continueUrl = getParameterByName("continueUrl");
// (Optional) Get the language code if available.
var lang = getParameterByName("lang") || "en";
// Configure the Firebase SDK.
// // This is the minimum configuration required for the API to be used.
// var config = {
// 'apiKey': "YOU_API_KEY" // Copy this key from the web initialization
// // snippet found in the Firebase console.
// };
// var app = firebase.initializeApp(config);
// var auth = firebase.auth();
if (!mode) {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(`Mode parameter not found`);
return;
}
if (!actionCode) {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(
`Action code parameter not found`
);
return;
}
// Handle the user management action.
switch (mode) {
case "resetPassword":
// Display reset password handler and UI.
$(".logo .text span").text("Reset Password");
document.title = "Reset Password | Monkeytype";
showResetPassword();
break;
case "recoverEmail":
// Display email recovery handler and UI.
handleRecoverEmail(actionCode);
break;
case "verifyEmail":
$(".logo .text span").text("Verify Email");
document.title = "Verify Email | Monkeytype";
// Display email verification handler and UI.
handleVerifyEmail(actionCode, continueUrl);
break;
default:
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(`Invalid mode`);
console.error("no mode found");
// Error: invalid mode.
}
$("#middle .resetPassword .button").click(() => {
handleResetPassword(actionCode, continueUrl);
});
$("#middle .resetPassword input").keypress((e) => {
if (e.key == "Enter") handleResetPassword(actionCode, continueUrl);
});
} catch (e) {
$("#middle .preloader .icon").html(
`<i class="fas fa-fw fa-times"></i>`
);
$("#middle .preloader .text").text(
`Fatal error: ${e.message}. If this issue persists, please report it.`
);
}
},
false
);
document.querySelector("#top").addEventListener("click", () => {
window.location = "/";
});
</script>
</html>