diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js index b7c433ba580..30f327232c6 100644 --- a/app/assets/javascripts/discourse/app/models/user.js +++ b/app/assets/javascripts/discourse/app/models/user.js @@ -423,6 +423,12 @@ const User = RestModel.extend({ return ajax(userPath(`${this.username_lower}/preferences/email`), { type: "POST", data: { email }, + }).then(() => { + if (!this.unconfirmed_emails) { + this.set("unconfirmed_emails", []); + } + + this.unconfirmed_emails.pushObject(email); }); }, @@ -430,6 +436,12 @@ const User = RestModel.extend({ return ajax(userPath(`${this.username_lower}/preferences/email`), { type: "PUT", data: { email }, + }).then(() => { + if (!this.unconfirmed_emails) { + this.set("unconfirmed_emails", []); + } + + this.unconfirmed_emails.pushObject(email); }); }, diff --git a/app/assets/javascripts/discourse/app/routes/app-route-map.js b/app/assets/javascripts/discourse/app/routes/app-route-map.js index f69417b55a8..d282ef4a188 100644 --- a/app/assets/javascripts/discourse/app/routes/app-route-map.js +++ b/app/assets/javascripts/discourse/app/routes/app-route-map.js @@ -179,7 +179,6 @@ export default function () { this.route("email"); this.route("second-factor"); - this.route("second-factor-backup"); }); this.route( diff --git a/app/assets/javascripts/discourse/app/routes/new-category.js b/app/assets/javascripts/discourse/app/routes/new-category.js index 8a0152174e7..f9244c28dce 100644 --- a/app/assets/javascripts/discourse/app/routes/new-category.js +++ b/app/assets/javascripts/discourse/app/routes/new-category.js @@ -3,8 +3,8 @@ import I18n from "I18n"; import { Promise } from "rsvp"; import { SEARCH_PRIORITIES } from "discourse/lib/constants"; -let _newCategoryColor = "0088CC", - _newCategoryTextColor = "FFFFFF"; +let _newCategoryColor = "0088CC"; +let _newCategoryTextColor = "FFFFFF"; export function setNewCategoryDefaultColors(backgroundColor, textColor) { _newCategoryColor = backgroundColor; @@ -12,6 +12,9 @@ export function setNewCategoryDefaultColors(backgroundColor, textColor) { } export default DiscourseRoute.extend({ + controllerName: "edit-category-tabs", + templateName: "edit-category-tabs", + beforeModel() { if (!this.currentUser) { this.replaceWith("/404"); @@ -71,11 +74,4 @@ export default DiscourseRoute.extend({ }, ]; }, - - renderTemplate() { - this.render("edit-category-tabs", { - controller: "edit-category-tabs", - model: this.currentModel, - }); - }, }); diff --git a/app/assets/javascripts/discourse/app/routes/preferences-email.js b/app/assets/javascripts/discourse/app/routes/preferences-email.js index 984a0e35c4d..375b7ff07e7 100644 --- a/app/assets/javascripts/discourse/app/routes/preferences-email.js +++ b/app/assets/javascripts/discourse/app/routes/preferences-email.js @@ -7,16 +7,12 @@ export default RestrictedUserRoute.extend({ return this.modelFor("user"); }, - renderTemplate() { - this.render({ into: "user" }); - }, - setupController(controller, model) { controller.reset(); controller.setProperties({ model, - oldEmail: controller.new ? "" : model.get("email"), - newEmail: controller.new ? "" : model.get("email"), + oldEmail: controller.new ? "" : model.email, + newEmail: controller.new ? "" : model.email, }); }, @@ -25,10 +21,4 @@ export default RestrictedUserRoute.extend({ controller.set("new", undefined); } }, - - // A bit odd, but if we leave to /preferences we need to re-render that outlet - deactivate() { - this._super(...arguments); - this.render("preferences", { into: "user", controller: "preferences" }); - }, }); diff --git a/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js b/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js index 46d296b2e52..10a21cf12dc 100644 --- a/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js +++ b/app/assets/javascripts/discourse/app/routes/preferences-second-factor.js @@ -1,19 +1,19 @@ import RestrictedUserRoute from "discourse/routes/restricted-user"; import { action } from "@ember/object"; +import { inject as service } from "@ember/service"; export default RestrictedUserRoute.extend({ + currentUser: service(), + siteSettings: service(), + showFooter: true, model() { return this.modelFor("user"); }, - renderTemplate() { - return this.render({ into: "user" }); - }, - setupController(controller, model) { - controller.setProperties({ model, newUsername: model.get("username") }); + controller.setProperties({ model, newUsername: model.username }); controller.set("loading", true); model @@ -39,17 +39,14 @@ export default RestrictedUserRoute.extend({ willTransition(transition) { this._super(...arguments); - const controller = this.controllerFor("preferences/second-factor"); - const user = controller.get("currentUser"); - const settings = controller.get("siteSettings"); - if ( transition.targetName === "preferences.second-factor" || - !user || - user.is_anonymous || - user.second_factor_enabled || - (settings.enforce_second_factor === "staff" && !user.staff) || - settings.enforce_second_factor === "no" + !this.currentUser || + this.currentUser.is_anonymous || + this.currentUser.second_factor_enabled || + (this.siteSettings.enforce_second_factor === "staff" && + !this.currentUser.staff) || + this.siteSettings.enforce_second_factor === "no" ) { return true; } diff --git a/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs b/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs index b630bc933e3..a48025158c1 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs @@ -190,7 +190,7 @@ {{#unless this.showEnforcedNotice}} {{/unless}} diff --git a/config/routes.rb b/config/routes.rb index bbba30dc3ef..c28d3d65c41 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -686,10 +686,6 @@ Discourse::Application.routes.draw do :constraints => { username: RouteFormat.username, } - get "#{root_path}/:username/preferences/second-factor-backup" => "users#preferences", - :constraints => { - username: RouteFormat.username, - } delete "#{root_path}/:username/preferences/user_image" => "users#destroy_user_image", :constraints => { username: RouteFormat.username,