jchristgit/programming-site

Discord Permission integration

jchristgit opened this issue · 0 comments

Django brings a feature-rich User authentication system that is also used by django-allauth (see my fork). Currently, all the integration we have with this is checking whether a user is logged in through user.is_authenticated. This is a bit sparse.

When a user is logged in, his permissions from the Discord server should be synchronized to the permissions of Django's user model:

  • user.is_member should be True if the associated Discord account is part of our Discord and has the Member role. We can check this by testing the user's permission bit flags against 0x10000 - that is, "Read Message History".
  • user.is_superuser should be True if the user has the Staff role on the Discord. Can be checked by using the 0x8 bit flag against the user's permission bit flags.

This can most likely be done through further customizing the DefaultSocialAccountAdapter of django-allauth on my fork - see this for further details.

An alternative for messing with the user attributes would be custom permissions, which are also supported by Django's authentication system.