wagtail-2fa
wagtail-2fa copied to clipboard
Adds a new custom permission that will show in the user admin.
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.
Related to issue https://github.com/labd/wagtail-2fa/issues/118