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:
parent
57e3323663
commit
b3aebca406
app
assets/javascripts/discourse/controllers
controllers/users
views/users/omniauth_callbacks
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue