FEATURE: allow auto provider to specify "full screen login"

this feature means we attempt to log in without opening a frame.
This commit is contained in:
Sam 2015-10-13 12:23:34 +11:00
parent 57e3323663
commit b3aebca406
3 changed files with 32 additions and 15 deletions

View File

@ -113,21 +113,26 @@ export default Ember.Controller.extend(ModalFunctionality, {
if(customLogin){ if(customLogin){
customLogin(); customLogin();
} else { } else {
this.set('authenticate', name); var authUrl = Discourse.getURL("/auth/" + name);
const left = this.get('lastX') - 400; if (loginMethod.get("full_screen_login")) {
const top = this.get('lastY') - 200; window.location = authUrl;
} else {
this.set('authenticate', name);
const left = this.get('lastX') - 400;
const top = this.get('lastY') - 200;
const height = loginMethod.get("frameHeight") || 400; const height = loginMethod.get("frameHeight") || 400;
const width = loginMethod.get("frameWidth") || 800; const width = loginMethod.get("frameWidth") || 800;
const w = window.open(Discourse.getURL("/auth/" + name), "_blank", const w = window.open(authUrl, "_blank",
"menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top); "menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top);
const self = this; const self = this;
const timer = setInterval(function() { const timer = setInterval(function() {
if(!w || w.closed) { if(!w || w.closed) {
clearInterval(timer); clearInterval(timer);
self.set('authenticate', null); self.set('authenticate', null);
} }
}, 1000); }, 1000);
}
} }
}, },

View File

@ -36,6 +36,18 @@ class Users::OmniauthCallbacksController < ApplicationController
@auth_result = authenticator.after_authenticate(auth) @auth_result = authenticator.after_authenticate(auth)
origin = request.env['omniauth.origin']
if origin.present?
parsed = URI.parse(@origin) rescue nil
if parsed
@origin = parsed.path
end
end
unless @origin.present?
@origin = Discourse.base_uri("/")
end
if @auth_result.failed? if @auth_result.failed?
flash[:error] = @auth_result.failed_reason.html_safe flash[:error] = @auth_result.failed_reason.html_safe
return render('failure') return render('failure')

View File

@ -26,7 +26,7 @@
window.opener.Discourse.authenticationComplete(<%=@auth_result.to_client_hash.to_json.html_safe%>); window.opener.Discourse.authenticationComplete(<%=@auth_result.to_client_hash.to_json.html_safe%>);
window.close(); window.close();
} else { } else {
window.location = '<%= Discourse.base_uri("/") %>'; window.location = <%= @origin.inspect %>;
} }
</script> </script>
</div> </div>