mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-21 13:57:57 -05:00
feat: approve users, edit users through manage users page (#1383)
This commit is contained in:
10
cms/auth_backends.py
Normal file
10
cms/auth_backends.py
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
Reference in New Issue
Block a user