improve structure
This commit is contained in:
parent
9efa4cbf4a
commit
b6bb6950e3
1 changed files with 6 additions and 6 deletions
|
|
@ -8,8 +8,12 @@ var audience = ''; // api audience as defined in auth0
|
|||
window.onload = function () {
|
||||
var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
|
||||
var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
||||
document.location.hash = '';
|
||||
if (accessToken) {
|
||||
if (!accessToken) {
|
||||
redirectUri = document.location.href;
|
||||
url = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+redirectUri;
|
||||
document.location = url;
|
||||
} else {
|
||||
document.location.hash = '';
|
||||
url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
|
|
@ -22,10 +26,6 @@ window.onload = function () {
|
|||
req.open("GET", url, true);
|
||||
req.setRequestHeader('X-Authorization', 'Bearer '+accessToken);
|
||||
req.send();
|
||||
} else {
|
||||
redirectUri = document.location.href;
|
||||
url = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+redirectUri;
|
||||
document.location = url;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue