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>
const ENDPOINT = '<?php echo LBRY::getApiUrl('/user_email/confirm')?>'
const 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}`;
var verifyUser = function(temporary_auth_token, email, verification_token, recaptcha) {
fetch(url)
.then(response => response.json())
.then(response => {
if (response.error)
throw Error(response.error);
document.getElementById("title").textContent = "Done!"
document.getElementById("verify").style.display = "none";
document.getElementById("verify-success").style.display = "block";
})
.catch(error => {
document.getElementById("title").textContent = "Uh oh"
document.getElementById("verify").style.display = "none";
document.getElementById("verify-error").style.display = "block";
document.getElementById("verify-error-text").textContent = error.message;
});
const url = `${ENDPOINT}?auth_token=${temporary_auth_token}&email=${encodeURIComponent(email)}&verification_token=${verification_token}&recaptcha=${recaptcha}`;
fetch(url)
.then(response => response.json())
.then((response) => {
if (response.error) {
throw Error(response.error)
}
document.getElementById("title").textContent = "Done!"
document.getElementById("verify").style.display = "none";
document.getElementById("verify-success").style.display = "block";
})
.catch(error => {
document.getElementById("title").textContent = "Uh oh"
document.getElementById("verify").style.display = "none";
document.getElementById("verify-error").style.display = "block";
document.getElementById("verify-error-text").textContent = error.message;
})
}
const verifyCallback = response => {
const urlParams = new URLSearchParams(window.location.search);
var verifyCallback = function(response) {
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');
const temporary_auth_token = urlParams.get('auth_token');
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";
document.getElementById("captcha-block").style.display = "none";
document.getElementById("verify").style.display = "block";
}
const expiredCallback = error => {
console.log("expired", error);
var expiredCallback = function(error) {
console.log("expired", error)
}
</script>
</head>

View file

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