fix VPNUser creation

master
alice 4 years ago
parent 223f6b60bf
commit c6bc79f342

@ -4,6 +4,7 @@ from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from django.db.models.signals import post_save
from django.db import IntegrityError
from django.dispatch import receiver
from constance import config as site_config
from django_lcore.core import LcoreUserProfileMethods, setup_sync_hooks, VPN_AUTH_STORAGE
@ -99,8 +100,11 @@ setup_sync_hooks(User, VPNUser)
@receiver(post_save, sender=User)
def create_vpnuser(sender, instance, created, **kwargs):
if created and not instance.vpnuser:
VPNUser.objects.create(user=instance)
if created:
try:
VPNUser.objects.create(user=instance)
except IntegrityError:
pass
class GiftCode(models.Model):

Loading…
Cancel
Save