wagtail-2fa icon indicating copy to clipboard operation
wagtail-2fa copied to clipboard

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

Open ollz272 opened this issue 2 years ago • 1 comments

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 avatar Oct 25 '22 16:10 ollz272

Related to issue https://github.com/labd/wagtail-2fa/issues/118

ollz272 avatar Oct 25 '22 16:10 ollz272