mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
Use AJAX for submitting Persona credentials.
Fixes issue with needing to unblock popups.
This commit is contained in:
parent
ef8cf2f734
commit
23d812a4ab
2 changed files with 15 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue