|
diff --git a/app/assets/javascripts/discourse/views/modal/login_view.js b/app/assets/javascripts/discourse/views/modal/login_view.js
index 05d662bc65..b510260b59 100644
--- a/app/assets/javascripts/discourse/views/modal/login_view.js
+++ b/app/assets/javascripts/discourse/views/modal/login_view.js
@@ -56,7 +56,11 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
}
_this.flash(result.error, 'error');
} else {
- return window.location.reload();
+ // Trigger the browser's password manager using the hidden static login form:
+ $('#hidden-login-form input[name=username]').val(_this.get('loginName'));
+ $('#hidden-login-form input[name=password]').val(_this.get('loginPassword'));
+ $('#hidden-login-form input[name=redirect]').val(window.location.href);
+ $('#hidden-login-form').submit();
}
}).fail(function(result) {
_this.flash(Em.String.i18n('login.error'), 'error');
@@ -143,6 +147,11 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
},
didInsertElement: function(e) {
+ // Get username and password from the browser's password manager,
+ // if it filled the hidden static login form:
+ this.set('loginName', $('#hidden-login-form input[name=username]').val());
+ this.set('loginPassword', $('#hidden-login-form input[name=password]').val());
+
var _this = this;
return Em.run.next(function() {
return $('#login-account-password').keydown(function(e) {
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 63e6e7e869..87386d1ce6 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -24,4 +24,14 @@ class StaticController < ApplicationController
render file: 'public/404', layout: false, status: 404
end
+ # This method just redirects to a given url.
+ # It's used when an ajax login was successful but we want the browser to see
+ # a post of a login form so that it offers to remember your password.
+ def enter
+ params.delete(:username)
+ params.delete(:password)
+ redirect_to(params[:redirect] || '/')
+ end
+
+
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 739fa52d0a..b4d310386d 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -21,6 +21,15 @@
+ <% unless current_user %>
+
+ <% end %>
+
<%=SiteCustomization.custom_header(session[:preview_style])%>
diff --git a/config/routes.rb b/config/routes.rb
index 299e2606f5..746aa06690 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -76,6 +76,7 @@ Discourse::Application.routes.draw do
end
resources :static
+ post 'login' => 'static#enter'
get 'faq' => 'static#show', id: 'faq'
get 'tos' => 'static#show', id: 'tos'
get 'privacy' => 'static#show', id: 'privacy'
|