mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 08:23:46 +00:00
Merge branch 'fix_paiement' into 'master'
Fix problème avec aes See merge request federez/re2o!69
This commit is contained in:
commit
cf6d0c5568
4 changed files with 12 additions and 12 deletions
|
@ -33,6 +33,8 @@ def decrypt(key, s):
|
||||||
|
|
||||||
class AESEncryptedField(models.CharField):
|
class AESEncryptedField(models.CharField):
|
||||||
def save_form_data(self, instance, data):
|
def save_form_data(self, instance, data):
|
||||||
|
if value is None:
|
||||||
|
return value
|
||||||
setattr(instance, self.name,
|
setattr(instance, self.name,
|
||||||
binascii.b2a_base64(encrypt(settings.AES_KEY, data)))
|
binascii.b2a_base64(encrypt(settings.AES_KEY, data)))
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ class AESEncryptedField(models.CharField):
|
||||||
binascii.a2b_base64(value)).decode('utf-8')
|
binascii.a2b_base64(value)).decode('utf-8')
|
||||||
|
|
||||||
def get_prep_value(self, value):
|
def get_prep_value(self, value):
|
||||||
|
if value is None:
|
||||||
|
return value
|
||||||
return binascii.b2a_base64(encrypt(
|
return binascii.b2a_base64(encrypt(
|
||||||
settings.AES_KEY,
|
settings.AES_KEY,
|
||||||
value
|
value
|
||||||
|
|
|
@ -18,9 +18,4 @@ class Migration(migrations.Migration):
|
||||||
name='payment_id',
|
name='payment_id',
|
||||||
field=models.CharField(max_length=255, null=True),
|
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),
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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 __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -13,14 +13,14 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='assooption',
|
||||||
|
name='payment_pass',
|
||||||
|
field=preferences.aes_field.AESEncryptedField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='assooption',
|
model_name='assooption',
|
||||||
name='payment_id',
|
name='payment_id',
|
||||||
field=models.CharField(default='', max_length=255),
|
field=models.CharField(default='', max_length=255),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assooption',
|
|
||||||
name='payment_pass',
|
|
||||||
field=preferences.aes_field.AESEncryptedField(default='', max_length=255),
|
|
||||||
),
|
|
||||||
]
|
]
|
|
@ -479,7 +479,8 @@ class AssoOption(models.Model):
|
||||||
)
|
)
|
||||||
payment_pass = AESEncryptedField(
|
payment_pass = AESEncryptedField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
default='',
|
null=True,
|
||||||
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue