Given that you have the following domains:
Domain A, Domain B and Domain C
The following users: user1 and user2.

and given that User1 is assigned to All Affiliates
and given that User2 is assigned only to domains B and C

Reproduction Steps

  1. Using User1, create a node (with the title "Sample Node" assigned to Domain A and Domain B
  2. Using User2, Edit "Sample Node" and change its title to "Another Node"

Actual Result

The node now ends up being acessible only from Domain B (and no longer accessible from Domain A) because user 1 was not able to reference Domain A from the node edit form (which is how things should be) Yet, the node should not change its reference however.

Expected Result

I'm not exactly sure what is the original design for that, but I think, it could be nice to just keep domains not acessible to a user to their orignal state (so domain A stays checked) because it shouldn't be up to the user to remove a node from other domains.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FooZee created an issue. See original summary.

agentrickard’s picture

This is a bug, and a nice report. Thank you.

The editor in this case should not have the ability to destroy domain assignments that they cannot access.

In Drupal 7 and below, we set a hidden field value to store that data and ensure it was not destroyed, and it looks like that is necessary again.

For reference, I had to do something similar here -- https://github.com/agentrickard/workbench_access/blob/8.x-1.x/workbench_...

Bunty Badgujar’s picture

Hi @agentrickard,

I'm facing the same problem. Can you please tell me, if this issue is going to fix in next release?

agentrickard’s picture

Yes. For now, you have to give everyone the 'Publish to any domain' permission as a workaround.

agentrickard’s picture

Status: Active » Needs work
FileSize
3.21 KB

Here is a very quick, totally untested patch.

agentrickard’s picture

FileSize
4.43 KB

Better patch that seems to be working.

However, if the user cannot "Send to all affiliates" if that option is not checked, I am getting access denied to the node, which doesn't make sense.

agentrickard’s picture

Status: Needs work » Needs review
FileSize
6.74 KB

This patch should fix the problem, but it still needs automated tests.

Please give it a try.

Note that we may have to do something similar for Domain Source.

agentrickard’s picture

agentrickard’s picture

FileSize
8.77 KB

Updated patch.

nghai’s picture

Thanks ken!

Patch #9 applied successfully against Domain Access 8.x-1.0-alpha4 release. The test results are as follow:

1) When node is assigned to single domain =>
-- Assigned Domain Source option is working as expected, do not get overridden.
-- Assigned Domain Access option is working as expected, do not get overridden.
-- Domain can be easily unassigned as well.

2) When node is assigned to multiple domains =>
-- Assigned Domain Source option is not working as expected, assigned source gets overridden on saving node from other domain.
-- Assigned Domain Access option is working as expected, do not get overridden.
-- Domain can be easily unassigned as well.

3) Nodes are easily accessible from other assigned Domains even when "Send to all affiliates" is not checked.

4) Links for nodes in Content Overview page and Views tabs (on node single views)
-- Currently links for the Node view/edit links are having base url as of assigned Domain Source even when viewed from other assigned valid Domain, should not it be the base url of current viewed Domain?
Or it is adapted like this intentionally ?

Over all the patch works fine so far except the assigned Domain Source Overridden case for multiple domains.

agentrickard’s picture

There are some interesting issues here, in order of the report above:

1) The base use-case works fine. Great.

2) The handler for Domain Source hidden options hasn't been written yet. If that is set to a domain the user cannot access, should the user be able to change it?

3) I assume you mean on the node/X page, and not in lists? This case is tough. If a user can edit / delete nodes assigned to their domains, and that node is displayed in a different context, you can't access edit/delete because those are denied if View is denied.

This comes from logic that I just changed, but I could restore the old behavior -- you must be on the proper domain in order to view/edit/delete. Fixing Domain Source handling would be a prerequisite of this.

4) If using Domain Source, all canonical links should be rewritten, regardless of context. Links should only go to currently viewed domain if Domain Source is not set.

nghai’s picture

Hey Ken, please find my reviews as below:

2.a) If User does not have access to the assigned Domain Source record then user should not be able to change it.
2.b) If User have the access for the assigned domain record then the user should able to change it to "none" or other domains (only if he has accesses).

3) I only meant the other problem that you mentioned in comment#6. Now there is no need to check "Send to all affiliates" options, it all works fine.

4) IMO the links other than canonical urls should go to currently viewed domain whether the Domain Source is assigned or not.

agentrickard’s picture

OK, good on issue #3, that's the fix I just put in place.

On #4, that would be a change in behavior. Drupal 8 now defines canonical links per entity -- generally View, Edit, Delete -- and those all get rewritten by Domain Source. That is by design and I don't think it should change.

What I haven't examined in Domain Source in D8 is the "none" behavior, which essentially should do what you describe.

agentrickard’s picture

FileSize
13.44 KB

Here's a revised version that should account for both Domain Access and Domain Source.

This patch introduces new services, so after applying this patch, you must rebuild the container using drush cr or a full cache clear.

agentrickard’s picture

To test (from #2818963: regular user not able to add content to the domain assigned):

* When a user cannot use the domain element at all, are the proper default field and node access values saved?

agentrickard’s picture

The use-case in #15 works as expected.

Screen shot of node access records for node created by unprivileged user.

agentrickard’s picture

Status: Needs review » Fixed

This should be fixed in Alpha6.

Sebastien M.’s picture

This patch seems no more applicable.
Could you update this patch or integrate it directly into DEV branch ?
Many thanks

Sebastien M.’s picture

I'm quite disappointed.
Parts of this patch are already applied to the DEV branch, some other parts are not applied or different.
I'm not able to update this patch without any risky drawback.

RobertoGuzman’s picture

nevermind

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.