Skip to content

Limit email template access by sender and receiver role #10403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 of 5 tasks
asmecher opened this issue Sep 12, 2024 · 10 comments
Closed
4 of 5 tasks

Limit email template access by sender and receiver role #10403

asmecher opened this issue Sep 12, 2024 · 10 comments
Assignees
Milestone

Comments

@asmecher
Copy link
Member

asmecher commented Sep 12, 2024

It's currently possible to create new email templates for mailables in a way that helps editors create their own email-based workflows. However, all mailables are available to all users when selecting a template, which can lead to inappropriate choices.

From e.g. Settings > Workflow > Emails > Add and edit templates > Discussion (Copyediting):
Image

When an assigned Copyeditor goes to create a new discussion in the Copyediting stage, their Choose a predefined message to use dropdown includes Request Copyedit, which is inappropriate.

To resolve this, we should add support for mailables to be designated as appropriate for certain user groups, so that when a user sees a list of possible email templates, they are only given a list that's relevant or appropriate to them. It should be possible to designate user groups when creating/editing an email template within a mailable. This should only be available on certain mailables, as not all will be related to submission workflow.

Update 2024-10-25: Specification

(from @ewhanson)

Initial steps should be to identify which roles should have access to which mailable templates as well as identifying all mailables across all applications and first-party plugins (if any). From an initial assessment of the feature, it doesn't seem like any new UI elements/pages will be necessary, but an additional todo for that work should be added if it's deemed necessary. Any mailables that roles do not have access to should not show up when creating new templates.

Note: Each todo below should be tracked as separate issues. This issue should only be closed once this work package has been finished entirely.

TODOs

@asmecher asmecher added this to OSS ORE Aug 29, 2024
@asmecher asmecher converted this from a draft issue Sep 12, 2024
@asmecher asmecher added this to the 3.6 milestone Sep 12, 2024
@mreiko mreiko moved this to Todo in PKP Public Roadmap Oct 24, 2024
@ewhanson ewhanson moved this from To Do to Specification In Progress in OSS ORE Oct 25, 2024
@ewhanson ewhanson moved this from Todo to In Progress in PKP Public Roadmap Oct 25, 2024
@ewhanson
Copy link
Contributor

ewhanson commented Oct 25, 2024

Hey @taslangraham, I've also assigned the issue for this work package to you. Have a look at the specification and todos above and let me know what you think. We can talk about any specific issues or questions you see in our one-on-one call on Monday.

@ewhanson ewhanson closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
@github-project-automation github-project-automation bot moved this from Specification In Progress to Backlog in OSS ORE Oct 25, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in PKP Public Roadmap Oct 25, 2024
@ewhanson ewhanson reopened this Oct 25, 2024
@ewhanson ewhanson moved this from Backlog to Specification In Progress in OSS ORE Oct 25, 2024
@ewhanson ewhanson moved this from Done to In Progress in PKP Public Roadmap Oct 25, 2024
@taslangraham
Copy link
Contributor

taslangraham commented Oct 28, 2024

@asmecher

Currently, each Mailable class has two properties: fromRoleIds and toRoleIds. These arrays hold the Role IDs of the groups designated to send and receive each Mailable. These properties could be used to control which templates are accessible and visible to a user.

However, in the issue, you mentioned that

It should be possible to designate user groups when creating/editing an email template within a Mailable.

Given that each Mailable can be restricted to specific groups, is it a case where we should also allow individual templates of a Mailable to be further limited to a subset of these allowed groups?

For example, if a Mailable is accessible to more than one role, should an individual template of this Mailable be configurable to allow access only to a single role?

@asmecher
Copy link
Member Author

Yes, individual templates should be assignable to sender roles. Think of a discussion template; if managers want to use that to orchestrate a workflow between author and editor, there will be a mix of templates each will use to compose messages. It will be confusing to authors if they see editor templates available for their use.

@asmecher
Copy link
Member Author

Some clarification and a mea culpa for the ambiguous language in the initial filing: The user working in settings should be able to designate which user groups (not role IDs) email templates can be sent by and sent to.

@mreiko mreiko moved this from In Review to Development In Progress in OSS ORE Feb 4, 2025
@taslangraham
Copy link
Contributor

Image

@Devika008 The image above shows the UI changes that I had made to the Add/Edit Email Template side modal while working on this feature.

Notes/thoughts/ideas/questions:

  • The Mark as Unrestricted option takes precedence over any selections made under Limit Access to Specific User Groups when checked. Would it make sense to disable those options automatically or hide the section entirely when Mark as Unrestricted is selected?
  • Initially, I used a simple list of checkboxes for selecting user groups, but a long list might feel overwhelming. We could consider using an auto-suggest component or a multi-select dropdown—though I’m not sure if such a component currently exists in our UI.
  • Currently, if a user selects a specific user group, saves the form, then later marks the template as unrestricted, both the unrestricted setting and the user group selection remain. However, the unrestricted setting takes precedence. If the user then unchecks the unrestricted option, the previously selected user groups become active again. Do you think this behavior make sense to users from a UI/UX perspective? Should we keep user group selections when Mark as Unrestricted is selected, or would it be better to clear them?

@Devika008
Copy link

Hi @taslangraham,

Thank you so much for reaching out regarding this issue.

Regarding the Notes/thoughts/ideas/questions:

  1. The Mark as Unrestricted option takes precedence over any selections made under Limit Access to Specific User Groups when checked. Would it make sense to disable those options automatically or hide the section entirely when Mark as Unrestricted is selected?

For a better user experience, I suggest displaying the question "Mark as unrestricted" with two radio button options:

  • Option 1: Mark as unrestricted
  • Option 2: Limit access to specific user groups
    The list of user groups should only appear after the user selects "Limit access to specific user groups." This keeps the interface clean and avoids unnecessary complexity upfront.
  1. Initially, I used a simple list of checkboxes for selecting user groups, but a long list might feel overwhelming. We could consider using an auto-suggest component or a multi-select dropdown—though I’m not sure if such a component currently exists in our UI.

An autosuggest component won’t work well here since it’s difficult to remember all the user groups that might exist.
I don’t believe we currently have a multi-select dropdown in the UI, which would be the ideal solution—but it might take time to develop. I’ll be sharing designs for this as part of the new multilingual form fields.
Until then, we can use a long list of checkboxes, and once the multi-select dropdown is ready, we can replace it for a smoother experience. 😊

  1. Currently, if a user selects a specific user group, saves the form, then later marks the template as unrestricted, both the unrestricted setting and the user group selection remain. However, the unrestricted setting takes precedence. If the user then unchecks the unrestricted option, the previously selected user groups become active again. Do you think this behavior make sense to users from a UI/UX perspective? Should we keep user group selections when Mark as Unrestricted is selected, or would it be better to clear them?

With the change mentioned in the first point, this issue won’t occur.

We need to make this an either-or selection, rather than allowing both options to remain active at the same time—otherwise, it can become confusing for the user.
Here’s how I suggest handling it:

  • If the user selects "Limit access to a user group", they can check a few user roles.
  • Later, if they change their mind and select "Mark as unrestricted", it should override the first selection, granting access to all users.
  • However, if they later switch back to "Limit access to a user group", we should restore their previously selected checkboxes, allowing them to keep or modify their earlier choices.
    This approach ensures clarity, prevents unnecessary complexity, and provides a smooth user experience.

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Mar 13, 2025
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Mar 15, 2025
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Mar 15, 2025
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Mar 17, 2025
taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Mar 20, 2025
taslangraham added a commit to taslangraham/pkp-docs that referenced this issue Mar 21, 2025
@taslangraham
Copy link
Contributor

taslangraham added a commit to taslangraham/pkp-lib that referenced this issue Apr 9, 2025
@ewhanson
Copy link
Contributor

ewhanson commented Apr 9, 2025

Awesome work @taslangraham! Feel free to squash and merge!

taslangraham added a commit that referenced this issue Apr 9, 2025
* #10571 WIP: Add checks to limit email template access by usergroups

* #10571 WIP: Allow admins and managers to assign user groups to email templates within a mailable

* #10571 WIP: add support for unrestricted templates

* #10571 Update emailTemplate schema

* #10571 Update locales

* #10571 Move migration into v3.6 folder

* #10571 add additional access checks

* #10571 Add migration to install process

* #10571 Make default templates unrestricted on Context creation

* #10571 Make templates assignable to all user groups

* #10571 Allow restriction to be set during template installation

* #10571 Update access on template deletion and template restore/reset

* #10571 Remove unnecessary email form components and clean up code

* #10650 Minor update  to emailTemplate.json schema

* #10403 Conditionally display user group options

* #10745 Add tests for email access restriction feature
@taslangraham
Copy link
Contributor

PRs for shared libraries and individual apps has been merged! Thanks for the review and general feedback on this one @ewhanson

@mreiko mreiko moved this from Development In Progress to In Review in OSS ORE Apr 10, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in PKP Public Roadmap May 5, 2025
@github-project-automation github-project-automation bot moved this from In Review to Backlog in OSS ORE May 5, 2025
@Tribunal33
Copy link
Contributor

Tribunal33 commented May 5, 2025

Tested and looks good. Automation is great too.

Image

Here are the test scenarios.

  1. Test Option Limit Access to specific user groups does block access to user with multiple roles
  2. Options for Unrestricted user groups are saved when default options is changed.
  3. Reset All Emails back to defaults button still works. Should revert any email with restricted access.
    (All automated below)
  4. Test UI layout option is added to Edit Email Templates. Mark as Unrestricted
  5. Test UI layout option is added to Edit Email Templates. Limit Access to Specific User Groups
  6. Test Option Mark as Unrestricted does not block access to user group
  7. Test Option Limit Access to specific user groups does block access to user group
  8. Tests that user cannot access restricted template not assigned to their group
  9. Tests that user can access unrestricted template not specifically assigned to their group
  10. Tests that user can access template assigned to their group

@mreiko mreiko moved this from Backlog to Done in OSS ORE May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

No branches or pull requests

6 participants