Skip to content

Instantly share code, notes, and snippets.

@DeadSuperHero
Created July 19, 2013 19:27
Show Gist options
  • Save DeadSuperHero/6041745 to your computer and use it in GitHub Desktop.
Save DeadSuperHero/6041745 to your computer and use it in GitHub Desktop.
Persona Login in my app automatically assumes error, even though the login is successful. What's wrong with my JS? :/
function personaLogin(url) {
navigator.id.get(function(assertion) {
if (assertion) {
// This code will be invoked once the user has successfully
// selected an email address they control to sign in with.
$.ajax({
url: '/users/sign_in',
type: "POST",
dataType: "json",
cache: false,
data: {
"assertion": assertion
},
success:function(data, status){
window.location.href = '/';
},
error:function(data, status){
alert(data.statusText + ": " + data.responseText);
}
});
} else {
// something went wrong! the user isn't logged in.
alert("Could not log you in!");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment