-
Notifications
You must be signed in to change notification settings - Fork 6
/
dialog.html
39 lines (39 loc) · 1.68 KB
/
dialog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<head>
<title>Connecting your remote storage</title>
<meta charset="utf-8">
<script src="js/require.js"></script>
<script>
require(['./js/src/remoteStorage'], function(remoteStorage) {
var bearerToken = remoteStorage.receiveToken();
if(bearerToken) {
document.write('And back to the application …');
localStorage.setItem('_unhosted$bearerToken', bearerToken);
localStorage.setItem('_unhosted$dialogResult', JSON.stringify({
err: null
}));
window.close();
} else {
localStorage.removeItem('_unhosted$dialogResult');
var userAddress = localStorage.getItem('_unhosted$userAddress');
document.write('Redirecting to your remote storage for "'+userAddress+'" …');
var categories = JSON.parse(localStorage.getItem('_unhosted$categories'));
remoteStorage.getStorageInfo(userAddress, function(err, storageInfo) {
if(err) {
localStorage.setItem('_unhosted$dialogResult', JSON.stringify({
err: err
}));
document.write('<br>Oops! That didn\'t work for "'+userAddress+'". Are you sure you have remote storage at that address? If not, <a href="http://unhosted.org">get a user address with remote storage</a>.');
} else {
localStorage.setItem('_unhosted$storageInfo', JSON.stringify(storageInfo));
var oauthAddress = remoteStorage.createOAuthAddress(storageInfo, categories, location.href);
window.location = oauthAddress;
}
});
}
});
</script>
</head>
<body>
</body>
</html>