Example #1
0
 def authenticate(self, user_id=None, password=None):
     try:
         user = User.objects.get(pk=user_id)
         known_passhash = gen_passhash(user)
         if password == known_passhash:
             return user
     except User.DoesNotExist:
         return None
Example #2
0
 def authenticate(self, user_id=None, password=None):
     try:
         user = User.objects.get(pk=user_id)
         known_passhash = gen_passhash(user)
         if password == known_passhash:
             return user
     except User.DoesNotExist:
         return None
Example #3
0
def user_create_barcode(sender, instance, created, **kwargs):
    instance = User.objects.get(email=instance.email)
    password_hash = gen_passhash(instance)
    qr = QRCode(8, QRErrorCorrectLevel.Q)
    qr.addData("####%s|%s" % (str(instance.pk), str(password_hash)))
    qr.make()
    im = qr.makeImage()
    temp_file = StringIO()

    # We'll take the username if we have to, but prefer first+last
    im.save(temp_file, format='png')
    barcode_contents = ContentFile(temp_file.getvalue())

    user_barcode = UserBarcode.objects.get_or_create(user=instance)[0]
    user_barcode.barcode.save('%s.png' % str(instance.pk), barcode_contents)

    if settings.PRINT_CARDS:
        print_card(instance, user_barcode.barcode.name)
    pass
Example #4
0
def user_create_barcode(sender, instance, created, **kwargs):
    instance = User.objects.get(email=instance.email)
    password_hash = gen_passhash(instance)
    qr = QRCode(8, QRErrorCorrectLevel.Q)
    qr.addData("####%s|%s" % (str(instance.pk), str(password_hash)))
    qr.make()
    im = qr.makeImage()
    temp_file = StringIO()

    # We'll take the username if we have to, but prefer first+last
    im.save(temp_file, format='png')
    barcode_contents = ContentFile(temp_file.getvalue())

    user_barcode = UserBarcode.objects.get_or_create(user=instance)[0]
    user_barcode.barcode.save('%s.png' % str(instance.pk), barcode_contents)

    if settings.PRINT_CARDS:
        print_card(instance, user_barcode.barcode.name)
    pass