Skip to content

Commit b6bb695

Browse files
committed
improve structure
1 parent 9efa4cb commit b6bb695

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/clients/auth0/vanilla.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
window.onload = function () {
99
var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
1010
var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
11-
document.location.hash = '';
12-
if (accessToken) {
11+
if (!accessToken) {
12+
redirectUri = document.location.href;
13+
url = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+redirectUri;
14+
document.location = url;
15+
} else {
16+
document.location.hash = '';
1317
url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
1418
var req = new XMLHttpRequest();
1519
req.onreadystatechange = function () {
@@ -22,10 +26,6 @@
2226
req.open("GET", url, true);
2327
req.setRequestHeader('X-Authorization', 'Bearer '+accessToken);
2428
req.send();
25-
} else {
26-
redirectUri = document.location.href;
27-
url = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+redirectUri;
28-
document.location = url;
2929
}
3030
};
3131
</script>

0 commit comments

Comments
 (0)