mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
defer persona init till after people launch the login dialog
This commit is contained in:
parent
d0b4c751b7
commit
ac905d4a08
@ -16,6 +16,31 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
|||||||
this.set('controller.lastY', e.screenY);
|
this.set('controller.lastY', e.screenY);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initPersona: function(){
|
||||||
|
var readyCalled = false;
|
||||||
|
navigator.id.watch({
|
||||||
|
onlogin: function(assertion) {
|
||||||
|
if (readyCalled) {
|
||||||
|
Discourse.ajax('/auth/persona/callback', {
|
||||||
|
type: 'POST',
|
||||||
|
data: { 'assertion': assertion },
|
||||||
|
dataType: 'json'
|
||||||
|
}).then(function(data) {
|
||||||
|
Discourse.authenticationComplete(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onlogout: function() {
|
||||||
|
if (readyCalled) {
|
||||||
|
Discourse.logout();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onready: function() {
|
||||||
|
readyCalled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement: function(e) {
|
didInsertElement: function(e) {
|
||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
@ -35,6 +60,12 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var view = this;
|
||||||
|
// load persona if needed
|
||||||
|
if(Discourse.SiteSettings.enable_persona_logins) {
|
||||||
|
$LAB.script("https://login.persona.org/include.js").wait(view.initPersona);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
<!-- TODO, move this into login UI, don't deliver with page -->
|
|
||||||
<script>
|
|
||||||
$LAB.script("https://login.persona.org/include.js").wait(function(){
|
|
||||||
(function() {
|
|
||||||
var readyCalled = false;
|
|
||||||
navigator.id.watch({
|
|
||||||
onlogin: function(assertion) {
|
|
||||||
if (readyCalled) {
|
|
||||||
Discourse.ajax('/auth/persona/callback', {
|
|
||||||
type: 'POST',
|
|
||||||
data: { 'assertion': assertion },
|
|
||||||
dataType: 'json'
|
|
||||||
}).then(function(data) {
|
|
||||||
Discourse.authenticationComplete(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onlogout: function() {
|
|
||||||
if (readyCalled) {
|
|
||||||
Discourse.logout();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onready: function() {
|
|
||||||
readyCalled = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
});
|
|
||||||
</script>
|
|
@ -69,7 +69,6 @@
|
|||||||
<footer id='bottom'></footer>
|
<footer id='bottom'></footer>
|
||||||
|
|
||||||
<%= render :partial => "common/discourse_javascript" %>
|
<%= render :partial => "common/discourse_javascript" %>
|
||||||
<%= render :partial => "common/persona_javascript" if !current_user && SiteSetting.enable_persona_logins %>
|
|
||||||
<%= render_google_analytics_code %>
|
<%= render_google_analytics_code %>
|
||||||
|
|
||||||
<!-- Discourse Version: <%= Discourse::VERSION::STRING %> -->
|
<!-- Discourse Version: <%= Discourse::VERSION::STRING %> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user