File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 8
8
window . onload = function ( ) {
9
9
var match = RegExp ( '[#&]access_token=([^&]*)' ) . exec ( window . location . hash ) ;
10
10
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 = '' ;
13
17
url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1' ;
14
18
var req = new XMLHttpRequest ( ) ;
15
19
req . onreadystatechange = function ( ) {
22
26
req . open ( "GET" , url , true ) ;
23
27
req . setRequestHeader ( 'X-Authorization' , 'Bearer ' + accessToken ) ;
24
28
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 ;
29
29
}
30
30
} ;
31
31
</ script >
You can’t perform that action at this time.
0 commit comments