Created
July 19, 2013 19:27
-
-
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? :/
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
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