Skip to content

Commit

Permalink
Add spinner when authenticating with 3rd party. Also handle when popu…
Browse files Browse the repository at this point in the history
…p window is closed without making a callback.
  • Loading branch information
nlalonde committed Jan 7, 2014
1 parent e732aa8 commit bcfaf52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
17 changes: 14 additions & 3 deletions app/assets/javascripts/discourse/controllers/login_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
}.property('loginName', 'loginPassword', 'loggingIn'),

showSignupLink: function() {
return !Discourse.SiteSettings.invite_only && !this.get('loggingIn');
}.property('loggingIn'),
return !Discourse.SiteSettings.invite_only && !this.get('loggingIn') && this.blank('authenticate');
}.property('loggingIn', 'authenticate'),

showSpinner: function() {
return this.get('loggingIn') || this.get('authenticate');
}.property('loggingIn', 'authenticate'),

actions: {
login: function() {
Expand Down Expand Up @@ -91,8 +95,15 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona

var height = loginMethod.get("frameHeight") || 400;
var width = loginMethod.get("frameWidth") || 800;
window.open(Discourse.getURL("/auth/" + name), "_blank",
var w = window.open(Discourse.getURL("/auth/" + name), "_blank",
"menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top);
var self = this;
var timer = setInterval(function() {
if(w.closed) {
clearInterval(timer);
self.set('authenticate', null);
}
}, 1000);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
<div id='login-alert' {{bindAttr class="alertClass"}}>{{alert}}</div>
</div>
<div class="modal-footer">
{{#if authenticate}}
{{i18n login.authenticating}}
{{/if}}
{{#if Discourse.SiteSettings.enable_local_logins}}
<button class='btn btn-large btn-primary'
{{bindAttr disabled="loginDisabled"}}
Expand All @@ -57,9 +54,13 @@
{{i18n create_account.action}}
</a>
{{/if}}
{{/if}}

{{#if loggingIn}}
&nbsp; <i class='fa fa-spinner fa-spin'></i>
{{/if}}
{{#if authenticate}}
&nbsp; {{i18n login.authenticating}}
{{/if}}

{{#if showSpinner}}
&nbsp; <i class='fa fa-spinner fa-spin'></i>
{{/if}}
</div>

0 comments on commit bcfaf52

Please sign in to comment.