FIX: allow admin to view any user's Billing page

This commit is contained in:
Faizaan Gagan 2022-06-13 17:41:35 +05:30
parent 46759c90cd
commit 3f45b1f19e
No known key found for this signature in database
GPG Key ID: 38AF5B87CC79B1BE
2 changed files with 11 additions and 7 deletions

View File

@ -1,10 +1,11 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import User from "discourse/models/user";
import { helperContext, registerUnbound } from "discourse-common/lib/helpers";
export default registerUnbound("user-viewing-self", function (model) {
if (User.current()) {
let currentUser = helperContext().currentUser;
if (currentUser) {
return (
User.current().username.toLowerCase() === model.username.toLowerCase()
currentUser.admin ||
currentUser.username?.toLowerCase() === model.username?.toLowerCase()
);
}

View File

@ -4,10 +4,13 @@ export default Route.extend({
templateName: "user/billing",
setupController(controller, model) {
if (this.currentUser.id !== this.modelFor("user").id) {
this.replaceWith("userActivity");
} else {
if (
this.currentUser.admin ||
this.currentUser.id === this.modelFor("user").id
) {
controller.setProperties({ model });
} else {
this.replaceWith("userActivity");
}
},
});