Last active
January 18, 2016 13:57
-
-
Save almet/82d730ce73ccc12e8d8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/calendar.js b/calendar.js | |
index ce462d6..faca709 100644 | |
--- a/calendar.js | |
+++ b/calendar.js | |
@@ -10,17 +10,29 @@ $(document).ready(function() { | |
// Local store in IndexedDB. | |
var store; | |
- | |
var headers; | |
// Authentication from location hash | |
authenticate(window.location.hash.slice(1)) | |
+ .then(function(authInfo) { | |
+ // Only do it if it's a FxA ! | |
+ | |
+ // We need to get the location of the user's server. | |
+ // 1. Create a new kinto instance, with the correct parameters. | |
+ // (remote: https://kinto.dev.mozaws.net/v1) -- central repository. | |
+ // 2. Do the request on the central repository to know if a server | |
+ // was configured for this user. | |
+ | |
+ // When you have the correct URL, you pass it in authInfo.storageServer. | |
+ return authInfo; | |
+ }) | |
.then(function (authInfo) { | |
+ console.log("Authentication Information", authInfo); | |
window.location.hash = authInfo.token; | |
headers = authInfo.headers; | |
// Kinto client with sync options. | |
- var kinto = new Kinto({remote: storageServer, | |
+ var kinto = new Kinto({remote: authInfo.storageServer, | |
bucket: bucket_id, | |
headers: headers, | |
dbPrefix: authInfo.username}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment