This commit is contained in:
ポール ウェッブ 2019-03-21 09:55:30 -05:00
parent 7814514938
commit c711fede6e
2 changed files with 129 additions and 96 deletions

View file

@ -1,75 +1,90 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Verify Your Identity</title> <title>Verify Your Identity</title>
<link rel="icon" href="images/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<link rel="icon" href="images/favicon.ico"/>
<script src='https://www.google.com/recaptcha/api.js?' async defer></script> <script src='https://www.google.com/recaptcha/api.js?' async defer></script>
<script type="text/javascript">
const ENDPOINT = '<?php echo LBRY::getApiUrl('/user_email/confirm')?>' <script>
const ENDPOINT = '<?php echo LBRY::getApiUrl('/user_email/confirm')?>'
var verifyUser = function(temporary_auth_token, email, verification_token, recaptcha) { 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}`;
const url = `${ENDPOINT}?auth_token=${temporary_auth_token}&email=${encodeURIComponent(email)}&verification_token=${verification_token}&recaptcha=${recaptcha}`; fetch(url)
fetch(url) .then(response => response.json())
.then(response => response.json()) .then((response) => {
.then((response) => { if (response.error)
if (response.error) { throw Error(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;
})
}
var verifyCallback = function(response) { document.getElementById("title").textContent = "Done!"
const urlParams = new URLSearchParams(window.location.search); document.getElementById("verify").style.display = "none";
const temporary_auth_token = urlParams.get('auth_token'); document.getElementById("verify-success").style.display = "block";
const email = urlParams.get('email') })
const verification_token = urlParams.get('verification_token'); .catch(error => {
// In the future we will have an `origin` query, to smartly redirect (or tell users they are verified) document.getElementById("title").textContent = "Uh oh"
// eg. if origin == "android" and device == "android" open the app, else say "your android app is verified" document.getElementById("verify").style.display = "none";
verifyUser(temporary_auth_token, email, verification_token, response); document.getElementById("verify-error").style.display = "block";
document.getElementById("verify-error-text").textContent = error.message;
});
}
document.getElementById("captcha-block").style.display = "none"; const verifyCallback = function(response) {
document.getElementById("verify").style.display = "block"; const urlParams = new URLSearchParams(window.location.search);
}
var expiredCallback = function(error) { const email = urlParams.get('email');
console.log("expired", error) 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";
}
const expiredCallback = error => {
console.log("expired", error);
}
</script> </script>
</head> </head>
<body>
<div style="display: flex; align-items: center; flex-direction: column;" class="text-center">
<img src="/img/lbry-dark-1600x528.png" style="max-height: 80px; margin-top: 50px; margin-bottom: 38px" alt="LBRY"/>
<h1 id="title">Almost Done!</h1>
<div id="captcha-block">
<p>Click the captcha to continue...</p>
<br/>
<div class="g-recaptcha" data-sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG" data-callback="verifyCallback" data-expired-callback="expiredCallback"></div>
</div>
<div style="display: none; margin-top: 10px;" id="verify"> <body>
<p>Verifying...</p> <main class="ancillary">
</div> <section class="hero hero--half-height">
<div style="display: none; margin-top: 10px;" id="verify-error"> <div class="inner-wrap inner-wrap--hero">
<code id="verify-error-text"></code> <h1>Almost Done!</h1>
<p style="margin-top: 10px">There was an error. Please make sure you are clicking the latest verification email and try again. Contact help@lbry.com if this keeps happening.</p> </div>
</div> </section>
<div style="display: none; margin-top: 10px;" id="verify-success">
<p class="spacer1">Success! Your email is now verified.</p> <section>
</div> <div class="inner-wrap">
</div> <div id="captcha-block">
</body> <p>Click the captcha to continue...</p>
<br/>
<div class="g-recaptcha" data-sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG" data-callback="verifyCallback" data-expired-callback="expiredCallback"></div>
</div>
<div style="display: none; margin-top: 10px;" id="verify">
<p>Verifying...</p>
</div>
<div style="display: none; margin-top: 10px;" id="verify-error">
<code id="verify-error-text"></code>
<p style="margin-top: 10px">There was an error. Please make sure you are clicking the latest verification email and try again. Contact help@lbry.com if this keeps happening.</p>
</div>
<div style="display: none; margin-top: 10px;" id="verify-success">
<p class="spacer1">Success! Your email is now verified.</p>
</div>
</div>
</section>
</main>
</body>
</html> </html>

View file

@ -1,46 +1,64 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Verify Your Identity</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Verify Your Identity</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="icon" href="images/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript"> <link rel="icon" href="images/favicon.ico"/>
var magicLink = "#";
var verifyCallback = function(response) { <script src='https://www.google.com/recaptcha/api.js'></script>
let payload = btoa(JSON.stringify({
<script>
let magicLink = "#";
const verifyCallback = response => {
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";
} }
</script> </script>
</head> </head>
<body>
<div style="display: flex; align-items: center; flex-direction: column;" class="text-center"> <body>
<img src="/img/lbry-dark-1600x528.png" style="max-height: 80px; margin-top: 50px;" alt="LBRY"/> <main class="ancillary">
<h1>Almost Done!</h1> <section class="hero hero--half-height">
<div id="captcha-block"> <div class="inner-wrap inner-wrap--hero">
<p>Click the captcha to continue...</p> <h1>Almost Done!</h1>
<br/> </div>
<div class="g-recaptcha" data-sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG" data-callback="verifyCallback" data-expired-callback="expiredCallback"></div> </section>
</div>
<div style=" display: none; margin-top: 10px;" id="success"> <section>
<p>Now click the magic link below to verify your identity in app...</p> <div class="inner-wrap">
<br/> <div id="captcha-block">
<a class="btn-primary btn-large spacer1" onclick="location.href=magicLink">Magic Link</a> <p>Click the captcha to continue...</p>
<p><i>When prompted, open the link with LBRY Browser on Android or LBRY on Desktop. Does the magic link not work? Not on the same device as the app? Paste this (very long) piece of text into the verification screen of the app to confirm your identity.</i></p> <br/>
<code class="multiline-code" id="magic-link-text"></code> <div class="g-recaptcha" data-sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG" data-callback="verifyCallback" data-expired-callback="expiredCallback"></div>
</div> </div>
</div>
</body> <div style="display: none; margin-top: 10px;" id="success">
<p>Now click the magic link below to verify your identity in app...</p>
<br/>
<a class="btn-primary btn-large spacer1" onclick="location.href=magicLink">Magic Link</a>
<p><i>When prompted, open the link with LBRY Browser on Android or LBRY on Desktop. Does the magic link not work? Not on the same device as the app? Paste this (very long) piece of text into the verification screen of the app to confirm your identity.</i></p>
<code class="multiline-code" id="magic-link-text"></code>
</div>
</div>
</section>
</main>
</body>
</html> </html>