Commit d8f8ba2e authored by Gabriel Detraz's avatar Gabriel Detraz Committed by Gabriel Detraz

Fix problème avec aes

parent 3dd87c94
......@@ -33,6 +33,8 @@ def decrypt(key, s):
class AESEncryptedField(models.CharField):
def save_form_data(self, instance, data):
if value is None:
return value
setattr(instance, self.name,
binascii.b2a_base64(encrypt(settings.AES_KEY, data)))
......@@ -49,6 +51,8 @@ class AESEncryptedField(models.CharField):
binascii.a2b_base64(value)).decode('utf-8')
def get_prep_value(self, value):
if value is None:
return value
return binascii.b2a_base64(encrypt(
settings.AES_KEY,
value
......
......@@ -18,9 +18,4 @@ class Migration(migrations.Migration):
name='payment_id',
field=models.CharField(max_length=255, null=True),
),
migrations.AddField(
model_name='assooption',
name='payment_pass',
field=preferences.aes_field.AESEncryptedField(max_length=255, null=True),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-01-14 23:10
# Generated by Django 1.10.7 on 2018-01-29 16:45
from __future__ import unicode_literals
from django.db import migrations, models
......@@ -13,14 +13,14 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterField(
migrations.AddField(
model_name='assooption',
name='payment_id',
field=models.CharField(default='', max_length=255),
name='payment_pass',
field=preferences.aes_field.AESEncryptedField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='assooption',
name='payment_pass',
field=preferences.aes_field.AESEncryptedField(default='', max_length=255),
name='payment_id',
field=models.CharField(default='', max_length=255),
),
]
......@@ -479,7 +479,8 @@ class AssoOption(models.Model):
)
payment_pass = AESEncryptedField(
max_length=255,
default='',
null=True,
blank=True,
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment