cloudservices/src/api/static/verify.html

47 lines
2.4 KiB
HTML

<!DOCTYPE html>
<head>
<title>Referral Verification</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
async function submit() {
try {
const input = document.getElementsByClassName('form-control')[0];
const response = await fetch(`https://api.cloud.libraryofcode.org/verify?t=${input.value}`);
if (response.status === 200) return alert('Request authorized. You may now close this tab.');
if (response.status === 401) return alert('Authorization Token incorrect, try again.');
if (response.status >= 500) return alert('INTERNAL SERVER ERROR');
} catch (err) {
alert(err);
}
}
</script>
</head>
<body>
<div class="container">
<h2>Referral Authorization Form</h2>
<p style="font-style: italic;">This form is for authorizing referral requests that you've provided to other users. If you've received this request from someone you don't recognize, please let us know right away.</p>
<div class="input-group mb-3">
<input id="auth" type="text" class="form-control" placeholder="Authorization Token" aria-label="Authorization Token" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="submit" onclick=submit()>Submit</button>
</div>
</div>
<footer class="text-center font-weight-light">Library of Code, Inc.</footer>
</div>
<script>
function listener(event) {
const input = document.getElementById('auth');
input.addEventListener('keydown', ({ key }) => {
if (key.toLowerCase() === "enter") submit();
});
}
listener();
</script>
</body>