Use AJAX for submitting Persona credentials.

Fixes issue with needing to unblock popups.
This commit is contained in:
Dan Callahan 2013-03-01 13:22:54 -06:00
parent ef8cf2f734
commit 23d812a4ab
2 changed files with 15 additions and 5 deletions

View file

@ -24,6 +24,11 @@ class Users::OmniauthCallbacksController < ApplicationController
when "persona"
create_or_sign_on_user_using_persona(auth_token)
end
respond_to do |format|
format.html
format.json { render :json => @data }
end
end
def failure

View file

@ -1,15 +1,20 @@
<script src="https://login.persona.org/include.js"></script>
<form id="persona_assertion_form" action="/auth/persona/callback" method="post" target="_blank">
<input type='hidden' name='assertion'/>
</form>
<script>
(function() {
var readyCalled = false;
navigator.id.watch({
onlogin: function(assertion) {
if (readyCalled) {
$('#persona_assertion_form input[name=assertion]').val(assertion);
$('#persona_assertion_form').submit();
$.ajax({
type: 'POST',
url: '/auth/persona/callback',
data: { 'assertion': assertion },
success: function(data, textStatus, jqXHR) {
Discourse.authenticationComplete(data);
},
dataType: 'json'
});
}
},
onlogout: function() {