Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<!DOCTYPE html>
<html lang="en">
<head>
<title>Django Login</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script type="text/javascript">
$(document).ready(function () {
const form_data = $('.form_phone');
form_data.submit(function () {
$.ajax({
url: '/ajaxpost',
type: 'POST',
data: form_data.serialize(),
csrfmiddlewaretoken: '{{ csrf_token }}',
success: function (data) {
console.log(data);
if (data['status_code'] === 200) {
Materialize.toast('Please Check your phone for confirmation', 2000);
$('#status').html(' Waiting for Confirmation <div class="preloader-wrapper small active">' +
'<div class="spinner-layer spinner-green-only">' +
'<div class="circle-clipper left">' +
'<div class="circle"></div>' +
'</div><div class="gap-patch">' +
'<div class="circle"></div>' +
'</div><div class="circle-clipper right">' +
'<div class="circle"></div>' +
'</div>' +
'</div>' +
'</div>');
const access_token = setInterval(check_access_token.bind(null, data['requestId']), 4000);
function check_access_token(requestId) {
$.ajax({
type: "GET",
url: "/auth/true-sdk",
data: {
'requestId': requestId
},
success: function (response) {
console.log(response);
if (response['status'] === 'OK') {
clearInterval(access_token);
$('#status').html('<h4>' + 'Welcome ' + response['name'] + '</h4>');
} else if (response['status'] === 'NO') {
console.log('Requesting');
} else {
console.log('ERROR');
clearInterval(access_token);
}
},
error: function () {
console.log('Error, Please refresh this page');
return false;
}
});
}
$(window).on("unload", function (e) {
clearInterval(access_token);
});
} else {
Materialize.toast('Error: ' + data['text'], 3000);
}
},
failure: function (data) {
alert('Got an error dude');
}
});
return false;
});
})
;
</script>
</head>
<body>
<div class="row">
<form class="col s12 form_phone" action="" method="post">{% csrf_token %}
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix">phone</i>
<input id="icon_telephone" type="tel" class="validate" name="phone_number" autocomplete="off">
<label for="icon_telephone">Phone Number</label>
<input type="submit" value="Submit"/>
</div>
<div class="col s4 offset-s4" id="status">
</div>
</div>
</form>
</div>
</body>
</html>