Skip to content

Commit

Permalink
[2.21.x] DDF-5946 Update Intrigue to respect Subject Identity configu…
Browse files Browse the repository at this point in the history
…ration (#5947)

* DDF-5946 Update Intrigue to respect Subject Identity configuration

* DDF-5946 Fix annotation update/delete

* DDF-5946 Capitalize User ID
  • Loading branch information
SmithJosh authored Mar 30, 2020
1 parent 7606fc0 commit 58d7ffb
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand All @@ -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!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const render = (props: Props) => {
{item.category === Category.User ? (
<EditableLabelText
value={item.value}
placeholder="[email protected]"
placeholder="User ID"
showLabel={false}
onChange={value => handleChangeInput(i, value)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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))
)
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const render = (props: Props) => {
<MenuAction
help="Brings up a view of the current
sharing settings for this workspace. From there, you can change what permissions each role has on the workspace,
as well as give permissions to individuals by specifying their email."
as well as give permissions to individuals by specifying their user id."
onClick={(_e, context) => {
viewSharing()
context.closeAndRefocus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function filterWorkspaces(workspaces: Backbone.Collection<Backbone.Model>) {
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
Expand Down

0 comments on commit 58d7ffb

Please sign in to comment.