From 58d7ffb0d9f620018c2326ef4411bcb13599103f Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Mon, 30 Mar 2020 07:24:41 -0700 Subject: [PATCH] [2.21.x] DDF-5946 Update Intrigue to respect Subject Identity configuration (#5947) * DDF-5946 Update Intrigue to respect Subject Identity configuration * DDF-5946 Fix annotation update/delete * DDF-5946 Capitalize User ID --- .../ui/metacard/MetacardApplication.java | 4 ++-- .../component/annotation/annotation.view.js | 4 ++-- .../webapp/component/editor/editor.view.js | 4 ++-- .../component/search-form/search-form.js | 4 ++-- .../tabs/search-form/tabs.search-form.js | 4 ++-- .../src/main/webapp/js/ApplicationStart.js | 2 +- .../react-component/sharing/presentation.tsx | 2 +- .../utils/security/security.tsx | 18 +++++++++--------- .../workspace-interactions/presentation.tsx | 2 +- .../workspaces-items/container.tsx | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/catalog/ui/catalog-ui-search/src/main/java/org/codice/ddf/catalog/ui/metacard/MetacardApplication.java b/catalog/ui/catalog-ui-search/src/main/java/org/codice/ddf/catalog/ui/metacard/MetacardApplication.java index c552d4b6aec7..52a865e8c934 100644 --- a/catalog/ui/catalog-ui-search/src/main/java/org/codice/ddf/catalog/ui/metacard/MetacardApplication.java +++ b/catalog/ui/catalog-ui-search/src/main/java/org/codice/ddf/catalog/ui/metacard/MetacardApplication.java @@ -812,7 +812,7 @@ public void init() { Attribute attribute = metacard.getAttribute(Core.METACARD_OWNER); if (attribute != null && attribute.getValue() != null - && !attribute.getValue().equals(getSubjectEmail())) { + && !attribute.getValue().equals(getSubjectIdentifier())) { res.status(401); return util.getResponseWrapper( ERROR_RESPONSE_TYPE, "Owner of note metacard is invalid!"); @@ -838,7 +838,7 @@ public void init() { Attribute attribute = metacard.getAttribute(Core.METACARD_OWNER); if (attribute != null && attribute.getValue() != null - && !attribute.getValue().equals(getSubjectEmail())) { + && !attribute.getValue().equals(getSubjectIdentifier())) { res.status(401); return util.getResponseWrapper( ERROR_RESPONSE_TYPE, "Owner of note metacard is invalid!"); diff --git a/ui/packages/catalog-ui-search/src/main/webapp/component/annotation/annotation.view.js b/ui/packages/catalog-ui-search/src/main/webapp/component/annotation/annotation.view.js index 6d7403dcd529..ad814f0c4614 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/component/annotation/annotation.view.js +++ b/ui/packages/catalog-ui-search/src/main/webapp/component/annotation/annotation.view.js @@ -37,7 +37,7 @@ module.exports = Marionette.LayoutView.extend({ 'click .footer-delete': 'handleDelete', }, initialize(options) { - this._useremail = userInstance.get('user').get('email') + this._userId = userInstance.getUserId() this._parent = options.parent }, handleDelete() { @@ -105,7 +105,7 @@ module.exports = Marionette.LayoutView.extend({ canModify() { this.$el.toggleClass( 'is-modifiable', - this._useremail === this.model.attributes.owner + this._userId === this.model.attributes.owner ) }, toggleDeleting() { diff --git a/ui/packages/catalog-ui-search/src/main/webapp/component/editor/editor.view.js b/ui/packages/catalog-ui-search/src/main/webapp/component/editor/editor.view.js index 028b3b586213..e6d350791fd2 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/component/editor/editor.view.js +++ b/ui/packages/catalog-ui-search/src/main/webapp/component/editor/editor.view.js @@ -101,7 +101,7 @@ module.exports = Marionette.LayoutView.extend({ ) }, handleTypes() { - const username = user.get('user').get('userid') + const userId = user.getUserId() let isOwner = true const types = {} this.model.forEach(result => { @@ -122,7 +122,7 @@ module.exports = Marionette.LayoutView.extend({ .get('properties') .get('metacard.owner') - isOwner = isOwner && username === metacardOwner + isOwner = isOwner && userId === metacardOwner }) this.$el.toggleClass('is-mixed', Object.keys(types).length > 1) this.$el.toggleClass('is-workspace', types.workspace !== undefined) diff --git a/ui/packages/catalog-ui-search/src/main/webapp/component/search-form/search-form.js b/ui/packages/catalog-ui-search/src/main/webapp/component/search-form/search-form.js index 8daad961b247..63be9d48cfae 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/component/search-form/search-form.js +++ b/ui/packages/catalog-ui-search/src/main/webapp/component/search-form/search-form.js @@ -21,8 +21,8 @@ module.exports = Backbone.Model.extend({ return { title: '', description: '', - createdBy: user.getEmail(), - owner: user.getEmail(), + createdBy: user.getUserId(), + owner: user.getUserId(), createdOn: Date.now(), type: 'custom', id: undefined, diff --git a/ui/packages/catalog-ui-search/src/main/webapp/component/tabs/search-form/tabs.search-form.js b/ui/packages/catalog-ui-search/src/main/webapp/component/tabs/search-form/tabs.search-form.js index 46c48c467b0b..a1eac69dc0fb 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/component/tabs/search-form/tabs.search-form.js +++ b/ui/packages/catalog-ui-search/src/main/webapp/component/tabs/search-form/tabs.search-form.js @@ -26,14 +26,14 @@ const formsTitle = properties.i18n['forms.title'] || 'Forms' const tabChildViewOptions = { [`My Search ${formsTitle}`]: { - filter: child => child.get('createdBy') === user.getEmail(), + filter: child => child.get('createdBy') === user.getUserId(), showNewForm: true, }, [`Shared Search ${formsTitle}`]: { type: 'Shared', filter: child => child.get('createdBy') !== 'system' && - child.get('createdBy') !== user.getEmail() && + child.get('createdBy') !== user.getUserId() && user.canRead(child), }, [`System Search ${formsTitle}`]: { diff --git a/ui/packages/catalog-ui-search/src/main/webapp/js/ApplicationStart.js b/ui/packages/catalog-ui-search/src/main/webapp/js/ApplicationStart.js index 19768e869c30..01d6b6bd2522 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/js/ApplicationStart.js +++ b/ui/packages/catalog-ui-search/src/main/webapp/js/ApplicationStart.js @@ -32,7 +32,7 @@ function getWorkspacesOwnedByUser() { workspace => user.isGuest() ? workspace.get('localStorage') === true - : workspace.get('metacard.owner') === user.get('user').get('email') + : workspace.get('metacard.owner') === user.getUserId() ) } diff --git a/ui/packages/catalog-ui-search/src/main/webapp/react-component/sharing/presentation.tsx b/ui/packages/catalog-ui-search/src/main/webapp/react-component/sharing/presentation.tsx index ecc38bb053ca..8b971907ceb7 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/react-component/sharing/presentation.tsx +++ b/ui/packages/catalog-ui-search/src/main/webapp/react-component/sharing/presentation.tsx @@ -126,7 +126,7 @@ const render = (props: Props) => { {item.category === Category.User ? ( handleChangeInput(i, value)} /> diff --git a/ui/packages/catalog-ui-search/src/main/webapp/react-component/utils/security/security.tsx b/ui/packages/catalog-ui-search/src/main/webapp/react-component/utils/security/security.tsx index ea99aef2b9c5..b6b7614cd6d3 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/react-component/utils/security/security.tsx +++ b/ui/packages/catalog-ui-search/src/main/webapp/react-component/utils/security/security.tsx @@ -95,7 +95,7 @@ export class Security { private canAccess(user: any, accessLevel: Access) { return ( this.res.owner === undefined || - this.res.owner === user.getEmail() || + this.res.owner === user.getUserId() || this.getAccess(user) >= accessLevel ) } @@ -136,16 +136,16 @@ export class Security { return Access.None } - private getIndividualAccess(email: string) { - if (this.res.accessAdministrators.indexOf(email) > -1) { + private getIndividualAccess(userId: string) { + if (this.res.accessAdministrators.indexOf(userId) > -1) { return Access.Share } - if (this.res.accessIndividuals.indexOf(email) > -1) { + if (this.res.accessIndividuals.indexOf(userId) > -1) { return Access.Write } - if (this.res.accessIndividualsRead.indexOf(email) > -1) { + if (this.res.accessIndividualsRead.indexOf(userId) > -1) { return Access.Read } @@ -154,7 +154,7 @@ export class Security { private getAccess(user: any): Access { return Math.max( - this.getIndividualAccess(user.getEmail()), + this.getIndividualAccess(user.getUserId()), ...user.getRoles().map((group: string) => this.getGroupAccess(group)) ) } @@ -180,10 +180,10 @@ export class Security { this.res.accessIndividualsRead, this.res.accessAdministrators ) - .map((username: string) => { + .map((userId: string) => { return { - value: username, - access: this.getIndividualAccess(username), + value: userId, + access: this.getIndividualAccess(userId), } as Entry }) .sort(Security.compareFn) diff --git a/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspace-interactions/presentation.tsx b/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspace-interactions/presentation.tsx index afd0027d2183..c4e483712fa9 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspace-interactions/presentation.tsx +++ b/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspace-interactions/presentation.tsx @@ -105,7 +105,7 @@ const render = (props: Props) => { { viewSharing() context.closeAndRefocus() diff --git a/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspaces-items/container.tsx b/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspaces-items/container.tsx index d9882a3f2f20..914354859e6b 100644 --- a/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspaces-items/container.tsx +++ b/ui/packages/catalog-ui-search/src/main/webapp/react-component/workspaces-items/container.tsx @@ -41,13 +41,13 @@ function filterWorkspaces(workspaces: Backbone.Collection) { return workspaces.filter((workspace: Backbone.Model) => { const localStorage = workspace.get('localStorage') || false const owner = workspace.get('metacard.owner') - const email = user.get('user').get('email') + const userId = user.getUserId() switch (preferences.get('homeFilter')) { case 'Not owned by me': - return !localStorage && email !== owner + return !localStorage && userId !== owner case 'Owned by me': - return localStorage || email === owner + return localStorage || userId === owner case 'Owned by anyone': default: return true