Externalize refresh token
This commit is contained in:
parent
38bc504a03
commit
9c0d7ed4bf
1 changed files with 23 additions and 16 deletions
|
@ -64,6 +64,9 @@
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js"></script>
|
||||||
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
|
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
var access_token;
|
||||||
|
var refresh_token;
|
||||||
|
var error;
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,9 +107,9 @@
|
||||||
|
|
||||||
var params = getHashParams();
|
var params = getHashParams();
|
||||||
|
|
||||||
var access_token = params.access_token,
|
access_token = params.access_token;
|
||||||
refresh_token = params.refresh_token,
|
refresh_token = params.refresh_token;
|
||||||
error = params.error;
|
error = params.error;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
alert('There was an error during the authentication');
|
alert('There was an error during the authentication');
|
||||||
|
@ -162,7 +165,7 @@
|
||||||
var currentElement = $(this);
|
var currentElement = $(this);
|
||||||
currentElement.addClass('active');
|
currentElement.addClass('active');
|
||||||
currentElement.addClass('loading');
|
currentElement.addClass('loading');
|
||||||
$('#dups').toggleClass('hide');
|
$('#dups').hide();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $(this).attr('href'),
|
url: $(this).attr('href'),
|
||||||
data: {
|
data: {
|
||||||
|
@ -189,25 +192,29 @@
|
||||||
pl_name: pl_name
|
pl_name: pl_name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('#dups').toggleClass('hide');
|
$('#dups').show();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '#obtain-new-token', function () {
|
$(document).on('click', '#obtain-new-token', function () {
|
||||||
var button = $(this);
|
refreshToken();
|
||||||
button.addClass('loading');
|
|
||||||
$.ajax({
|
|
||||||
url: '/refresh_token',
|
|
||||||
data: {
|
|
||||||
'refresh_token': refresh_token
|
|
||||||
}
|
|
||||||
}).done(function (data) {
|
|
||||||
access_token = data.access_token;
|
|
||||||
button.removeClass('loading');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
function refreshToken() {
|
||||||
|
var button = $('#obtain-new-token');
|
||||||
|
button.addClass('loading');
|
||||||
|
$.ajax({
|
||||||
|
url: '/refresh_token',
|
||||||
|
data: {
|
||||||
|
'refresh_token': refresh_token
|
||||||
|
}
|
||||||
|
}).done(function (data) {
|
||||||
|
access_token = data.access_token;
|
||||||
|
button.removeClass('loading');
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue