diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 index 152aabadde9..172bd050e27 100644 --- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 +++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 @@ -87,6 +87,7 @@ export default function() { this.route('signup', {path: '/signup'}); this.route('login', {path: '/login'}); + this.route('login-preferences'); this.route('forgot-password', {path: '/password-reset'}); this.route('faq', {path: '/faq'}); this.route('tos', {path: '/tos'}); diff --git a/app/assets/javascripts/discourse/routes/build-static-route.js.es6 b/app/assets/javascripts/discourse/routes/build-static-route.js.es6 new file mode 100644 index 00000000000..eab6d406228 --- /dev/null +++ b/app/assets/javascripts/discourse/routes/build-static-route.js.es6 @@ -0,0 +1,18 @@ +import DiscourseRoute from 'discourse/routes/discourse'; + +export default function(pageName) { + const route = { + model() { + return Discourse.StaticPage.find(pageName); + }, + + renderTemplate() { + this.render('static'); + }, + + setupController(controller, model) { + this.controllerFor('static').set('model', model); + } + }; + return DiscourseRoute.extend(route); +} diff --git a/app/assets/javascripts/discourse/routes/forgot-password.js.es6 b/app/assets/javascripts/discourse/routes/forgot-password.js.es6 index 3985fa1b1a3..df8ab36145b 100644 --- a/app/assets/javascripts/discourse/routes/forgot-password.js.es6 +++ b/app/assets/javascripts/discourse/routes/forgot-password.js.es6 @@ -1,22 +1,13 @@ -export default Discourse.Route.extend({ - beforeModel: function() { - this.replaceWith(this.controllerFor('application').get('loginRequired') ? 'login' : 'discovery').then(function(e) { - Ember.run.next(function() { - e.send('showForgotPassword'); - }); +import buildStaticRoute from 'discourse/routes/build-static-route'; + +const ForgotPasswordRoute = buildStaticRoute('password-reset'); + +ForgotPasswordRoute.reopen({ + beforeModel() { + this.replaceWith(this.controllerFor('application').get('loginRequired') ? 'login' : 'discovery').then(e => { + Ember.run.next(() => e.send('showForgotPassword')); }); }, - - model: function() { - return Discourse.StaticPage.find('password-reset'); - }, - - renderTemplate: function() { - // do nothing - this.render('static'); - }, - - setupController: function(controller, model) { - this.controllerFor('static').set('model', model); - } }); + +export default ForgotPasswordRoute; diff --git a/app/assets/javascripts/discourse/routes/login.js.es6 b/app/assets/javascripts/discourse/routes/login.js.es6 index 36498f6accd..ad8e840f1a1 100644 --- a/app/assets/javascripts/discourse/routes/login.js.es6 +++ b/app/assets/javascripts/discourse/routes/login.js.es6 @@ -1,24 +1,15 @@ -export default Discourse.Route.extend({ - beforeModel: function() { - if (!Discourse.SiteSettings.login_required) { - this.replaceWith('discovery.latest').then(function(e) { - Ember.run.next(function() { - e.send('showLogin'); - }); +import buildStaticRoute from 'discourse/routes/build-static-route'; + +const LoginRoute = buildStaticRoute('login'); + +LoginRoute.reopen({ + beforeModel() { + if (!this.siteSettings.login_required) { + this.replaceWith('discovery.latest').then(e => { + Ember.run.next(() => e.send('showLogin')); }); } - }, - - model: function() { - return Discourse.StaticPage.find('login'); - }, - - renderTemplate: function() { - // do nothing - this.render('static'); - }, - - setupController: function(controller, model) { - this.controllerFor('static').set('model', model); } }); + +export default LoginRoute; diff --git a/app/assets/javascripts/discourse/templates/login-preferences.hbs b/app/assets/javascripts/discourse/templates/login-preferences.hbs new file mode 100644 index 00000000000..6c2db36aa66 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/login-preferences.hbs @@ -0,0 +1,8 @@ +
{{i18n "login.preferences"}}
+ + {{d-button class="btn-primary" action="showLogin" label="log_in"}} + {{d-button action="showForgotPassword" label="login.forgot"}} +