FIX: correctly allows admin to visit a user chat's preferences page (#19619)

This commit is contained in:
Joffrey JAFFEUX 2022-12-23 21:18:09 +01:00 committed by GitHub
parent 03d32f26bb
commit df11457d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
{{#if (or this.model.can_chat this.model.admin)}} {{#if (or this.model.can_chat this.currentUser.admin)}}
<LinkTo @route="preferences.chat"> <LinkTo @route="preferences.chat">
{{i18n "chat.title_capitalized"}} {{i18n "chat.title_capitalized"}}
</LinkTo> </LinkTo>

View File

@ -8,7 +8,7 @@ export default class PreferencesChatRoute extends RestrictedUserRoute {
showFooter = true; showFooter = true;
setupController(controller, user) { setupController(controller, user) {
if (!user?.can_chat && !user.admin) { if (!user?.can_chat && !this.currentUser.admin) {
return this.transitionTo(`discovery.${defaultHomepage()}`); return this.transitionTo(`discovery.${defaultHomepage()}`);
} }
controller.set("model", user); controller.set("model", user);

View File

@ -34,7 +34,7 @@ RSpec.describe "User chat preferences", type: :system, js: true do
context "as an admin on another user's preferences" do context "as an admin on another user's preferences" do
fab!(:current_user) { Fabricate(:admin) } fab!(:current_user) { Fabricate(:admin) }
fab!(:user_1) { Fabricate(:admin) } fab!(:user_1) { Fabricate(:user) }
before { sign_in(current_user) } before { sign_in(current_user) }