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
app
assets/javascripts/discourse/controllers
controllers/users
views/users/omniauth_callbacks

View File

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

View File

@ -36,6 +36,18 @@ class Users::OmniauthCallbacksController < ApplicationController
@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?
flash[:error] = @auth_result.failed_reason.html_safe
return render('failure')

View File

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