Skip to content

A platform for community discussion. Free, open, simple.

DEV: Make user card non-clickable for anon users: (#15938)

janzenisaacee050e506321
diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js
index ca41e8eabed..a32d87d7309 100644
--- a/app/assets/javascripts/discourse/app/widgets/post.js
+++ b/app/assets/javascripts/discourse/app/widgets/post.js
@@ -173,6 +173,8 @@ createWidget("post-avatar", {
html(attrs) {
let body;
+ let hideFromAnonUser =
+ this.siteSettings.hide_user_profiles_from_public && !this.currentUser;
if (!attrs.user_id) {
body = iconNode("far-trash-alt", { class: "deleted-user-avatar" });
} else {
@@ -181,7 +183,7 @@ createWidget("post-avatar", {
username: attrs.username,
name: attrs.name,
url: attrs.usernameUrl,
- className: "main-avatar",
+ className: `main-avatar ${hideFromAnonUser ? "non-clickable" : ""}`,
hideTitle: true,
});
}
diff --git a/app/assets/javascripts/discourse/app/widgets/poster-name.js b/app/assets/javascripts/discourse/app/widgets/poster-name.js
index 441fda53fdf..2308b77155a 100644
--- a/app/assets/javascripts/discourse/app/widgets/poster-name.js
+++ b/app/assets/javascripts/discourse/app/widgets/poster-name.js
@@ -58,6 +58,12 @@ export default createWidget("poster-name", {
attributes: {
href: attrs.usernameUrl,
"data-user-card": attrs.username,
+ class: `${
+ this.siteSettings.hide_user_profiles_from_public &&
+ !this.currentUser
+ ? "non-clickable"
+ : ""
+ }`,
},
},
formatUsername(text)
diff --git a/app/assets/stylesheets/common/foundation/helpers.scss b/app/assets/stylesheets/common/foundation/helpers.scss
index e06dda77a0b..2fc2324e27c 100644
--- a/app/assets/stylesheets/common/foundation/helpers.scss
+++ b/app/assets/stylesheets/common/foundation/helpers.scss
@@ -76,3 +76,7 @@
.clickable {
cursor: pointer;
}
+
+.non-clickable {
+ cursor: default;
+}