SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit aa7b460c authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Fix keys generator

parent cbefe562
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-02-20 10:39
from __future__ import unicode_literals
import datetime
import hashlib
import random
import string
from django.utils import timezone
from django.db import migrations
# Hack
......@@ -92,7 +97,15 @@ def transfer_old_invitations_to_new_tables(apps, schema_editor):
)
if new_inv.invitation_type in ['ci', 'cp']:
new_inv.invitation_type = 'C'
new_inv.refresh_keys(force_new_key=True)
# Generate keys, custom methods are not loaded here
salt = ''
for i in range(5):
salt += random.choice(string.ascii_letters)
salt = salt.encode('utf8')
invitationsalt = new_inv.last_name.encode('utf8')
new_inv.invitation_key = hashlib.sha1(salt + invitationsalt).hexdigest()
new_inv.key_expires = timezone.now() + datetime.timedelta(days=365)
new_inv.save()
if invitation.cited_in_submission:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment