Skip to content

Adds a new custom permission that will show in the user admin.#193

Open
ollz272 wants to merge 1 commit into
labd:masterfrom
ollz272:fix-permissions-bug
Open

Adds a new custom permission that will show in the user admin.#193
ollz272 wants to merge 1 commit into
labd:masterfrom
ollz272:fix-permissions-bug

Conversation

@ollz272
Copy link
Copy Markdown

@ollz272 ollz272 commented Oct 25, 2022

Im not sure when this bug occurred, but at the moment its not possible to see the enable_2fa permission in the groups admin. This is because of this bit of wagtail code:

    for content_type_id in content_type_ids:
        content_perms = permissions.filter(content_type_id=content_type_id)
        content_perms_dict = {}
        custom_perms = []

        if content_perms[0].content_type.name == "admin":
            perm = content_perms[0]
            other_perms.append((perm, checkboxes_by_id[perm.id]))
            continue

https://github.com/wagtail/wagtail/blob/main/wagtail/users/templatetags/wagtailusers_tags.py#L55-L65

Essentially, it only grabs the first permission for the admin content type. So the one for Wagtail 2FA gets left out.
For a project im working on i've had to create some custom permissions and middleware to get around this. But i believe we can fix it here.

I've simply created a new permission under the wagtail_2fa contentype. This means it will be treated like any other custom permission to wagtail and show in the admin.

@ollz272
Copy link
Copy Markdown
Author

ollz272 commented Oct 25, 2022

Related to issue #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant