mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 07:28:53 -05:00
11 lines
414 B
Python
11 lines
414 B
Python
from django.conf import settings
|
|
from django.contrib.auth.backends import ModelBackend
|
|
|
|
|
|
class ApprovalBackend(ModelBackend):
|
|
def user_can_authenticate(self, user):
|
|
can_authenticate = super().user_can_authenticate(user)
|
|
if can_authenticate and settings.USERS_NEEDS_TO_BE_APPROVED and not user.is_superuser:
|
|
return getattr(user, 'is_approved', False)
|
|
return can_authenticate
|