Skip to content

Commit 39b395c

Browse files
Hide property has sensitive data with normal user (#19857)
Co-authored-by: Lan Nguyen Thuy <[email protected]>
1 parent 20e47d5 commit 39b395c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Umbraco.Web.UI.Client/src/packages/content/content/global-components/content-workspace-property.element.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
55
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
66
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
77
import { UmbDataPathPropertyValueQuery } from '@umbraco-cms/backoffice/validation';
8+
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
89

910
@customElement('umb-content-workspace-property')
1011
export class UmbContentWorkspacePropertyElement extends UmbLitElement {
@@ -37,6 +38,9 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
3738
@state()
3839
_propertyType?: UmbPropertyTypeModel;
3940

41+
@state()
42+
private _hasAccessToSensitiveData = false;
43+
4044
constructor() {
4145
super();
4246

@@ -51,6 +55,12 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
5155
this._workspaceContext = workspaceContext;
5256
this.#observePropertyType();
5357
});
58+
59+
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (context) => {
60+
this.observe(context?.hasAccessToSensitiveData, (hasAccessToSensitiveData) => {
61+
this._hasAccessToSensitiveData = hasAccessToSensitiveData === true;
62+
});
63+
});
5464
}
5565

5666
async #observePropertyType() {
@@ -119,6 +129,7 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
119129
override render() {
120130
if (!this._viewable) return nothing;
121131
if (!this._dataPath || this._writeable === undefined) return nothing;
132+
if (!this._hasAccessToSensitiveData && this._propertyType?.isSensitive) return nothing;
122133

123134
return html`<umb-property-type-based-property
124135
data-path=${this._dataPath}

0 commit comments

Comments
 (0)