Revert JS changes on verify pages

This commit is contained in:
ポール ウェッブ 2019-03-21 13:34:21 -05:00
parent f6c133abe4
commit c65078f94e
2 changed files with 34 additions and 39 deletions

View file

@ -14,43 +14,42 @@
<script> <script>
const ENDPOINT = '<?php echo LBRY::getApiUrl('/user_email/confirm')?>' const ENDPOINT = '<?php echo LBRY::getApiUrl('/user_email/confirm')?>'
const verifyUser = function(temporary_auth_token, email, verification_token, recaptcha) { var verifyUser = function(temporary_auth_token, email, verification_token, recaptcha) {
const url = `${ENDPOINT}?auth_token=${temporary_auth_token}&email=${encodeURIComponent(email)}&verification_token=${verification_token}&recaptcha=${recaptcha}`;
fetch(url) const url = `${ENDPOINT}?auth_token=${temporary_auth_token}&email=${encodeURIComponent(email)}&verification_token=${verification_token}&recaptcha=${recaptcha}`;
.then(response => response.json()) fetch(url)
.then(response => { .then(response => response.json())
if (response.error) .then((response) => {
throw Error(response.error); if (response.error) {
throw Error(response.error)
document.getElementById("title").textContent = "Done!" }
document.getElementById("verify").style.display = "none"; document.getElementById("title").textContent = "Done!"
document.getElementById("verify-success").style.display = "block"; document.getElementById("verify").style.display = "none";
}) document.getElementById("verify-success").style.display = "block";
.catch(error => { })
document.getElementById("title").textContent = "Uh oh" .catch(error => {
document.getElementById("verify").style.display = "none"; document.getElementById("title").textContent = "Uh oh"
document.getElementById("verify-error").style.display = "block"; document.getElementById("verify").style.display = "none";
document.getElementById("verify-error-text").textContent = error.message; document.getElementById("verify-error").style.display = "block";
}); document.getElementById("verify-error-text").textContent = error.message;
})
} }
const verifyCallback = response => { var verifyCallback = function(response) {
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const temporary_auth_token = urlParams.get('auth_token');
const email = urlParams.get('email')
const verification_token = urlParams.get('verification_token');
// In the future we will have an `origin` query, to smartly redirect (or tell users they are verified)
// eg. if origin == "android" and device == "android" open the app, else say "your android app is verified"
verifyUser(temporary_auth_token, email, verification_token, response);
const email = urlParams.get('email'); document.getElementById("captcha-block").style.display = "none";
const temporary_auth_token = urlParams.get('auth_token'); document.getElementById("verify").style.display = "block";
const verification_token = urlParams.get('verification_token');
// In the future we will have an `origin` query, to smartly redirect (or tell users they are verified)
// eg. if origin == "android" and device == "android" open the app, else say "your android app is verified"
verifyUser(temporary_auth_token, email, verification_token, response);
document.getElementById("captcha-block").style.display = "none";
document.getElementById("verify").style.display = "block";
} }
const expiredCallback = error => { var expiredCallback = function(error) {
console.log("expired", error); console.log("expired", error)
} }
</script> </script>
</head> </head>

View file

@ -12,22 +12,18 @@
<script src='https://www.google.com/recaptcha/api.js'></script> <script src='https://www.google.com/recaptcha/api.js'></script>
<script> <script>
let magicLink = "#"; var magicLink = "#";
var verifyCallback = function(response) {
const verifyCallback = response => { let payload = btoa(JSON.stringify({
const payload = btoa(JSON.stringify({
recaptcha: response, recaptcha: response,
token: "<?php echo $token ?>" token: "<?php echo $token ?>"
})); }));
magicLink = "lbry://?verify=" + payload; magicLink = "lbry://?verify=" + payload;
document.getElementById("magic-link-text").textContent = payload; document.getElementById("magic-link-text").textContent = payload;
document.getElementById("success").style.display = "block"; document.getElementById("success").style.display = "block";
document.getElementById("captcha-block").style.display = "none"; document.getElementById("captcha-block").style.display = "none";
}; };
var expiredCallback = function() {
const expiredCallback = () => {
document.getElementById("success").style.display = "none"; document.getElementById("success").style.display = "none";
document.getElementById("captcha-block").style.display = "block"; document.getElementById("captcha-block").style.display = "block";
} }