DEV: Remove renderTemplate from 2fa preferences, email preferences, and new-category (#22156)

This commit is contained in:
Jarek Radosz 2023-06-16 16:50:45 +02:00 committed by GitHub
parent 37030ed348
commit 9984accfa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 41 deletions

View File

@ -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);
});
},

View File

@ -179,7 +179,6 @@ export default function () {
this.route("email");
this.route("second-factor");
this.route("second-factor-backup");
});
this.route(

View File

@ -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,
});
},
});

View File

@ -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" });
},
});

View File

@ -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;
}

View File

@ -190,7 +190,7 @@
{{#unless this.showEnforcedNotice}}
<CancelLink
@route="preferences.account"
@route="preferences.security"
@args={{this.model.username}}
/>
{{/unless}}

View File

@ -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,