first commit
This commit is contained in:
13
accounts/signals.py
Normal file
13
accounts/signals.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def deactivate_new_ldap_user(sender, instance, created, **kwargs):
|
||||
# Jika user baru saja dibuat di database lokal dan dia adalah akun LDAP
|
||||
# (ditandai dengan tidak adanya password lokal/usable password)
|
||||
if created and not instance.has_usable_password():
|
||||
# Otomatis matikan keaktifannya agar statusnya menjadi "Menunggu Persetujuan"
|
||||
instance.is_active = False
|
||||
instance.save()
|
||||
|
||||
Reference in New Issue
Block a user