Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
function displayManage() { | ||
$.get('/api/whoami', function (res) { | ||
if (res === null) { | ||
$("#auth").show(); | ||
} else { | ||
showControl(); | ||
} | ||
}, 'json'); | ||
} | ||
|
||
function showControl() { | ||
alert("now you get the control pane!"); | ||
} | ||
|
||
// a handler that is passed an assertion after the user logs in via the | ||
// browserid dialog | ||
function gotVerifiedEmail(assertion) { | ||
// got an assertion, now send it up to the server for verification | ||
if (assertion !== null) { | ||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/login', | ||
data: { assertion: assertion }, | ||
success: function(res, status, xhr) { | ||
showControl(); | ||
}, | ||
error: function(res, status, xhr) { | ||
alert("login failure" + res); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
// at startup let's check to see whether we're authenticated to | ||
// myfavoritebeer (have existing cookie), and update the UI accordingly | ||
$(document).ready(function() { | ||
|
||
// when the user clicks on 'add a hack'... | ||
$("#add_a_hack").click(function() { | ||
$("#manage > *").hide(); | ||
$("#overview").fadeOut(200, function() { | ||
$("#manage").fadeIn(200); | ||
}); | ||
|
||
// hit the api to see which div to display | ||
displayManage(); | ||
}); | ||
|
||
// when the user clicks sign in from the manage page... | ||
$("#sign_in").click(function() { | ||
navigator.id.getVerifiedEmail(gotVerifiedEmail); | ||
}); | ||
|
||
}); |