Add hash password
This commit is contained in:
parent
be0412ffae
commit
b8d9a1344b
|
|
@ -11,7 +11,7 @@ class Command(BaseCommand):
|
||||||
def account_sql(self):
|
def account_sql(self):
|
||||||
with connections['legacy'].cursor() as cursor:
|
with connections['legacy'].cursor() as cursor:
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
select a.email, a.id as account_id
|
select a.email, a.id as account_id, a.encrypted_password
|
||||||
from accounts as a
|
from accounts as a
|
||||||
where a.email is not null
|
where a.email is not null
|
||||||
and a.email not in ('cyril@tomatic.net',
|
and a.email not in ('cyril@tomatic.net',
|
||||||
|
|
@ -20,7 +20,7 @@ class Command(BaseCommand):
|
||||||
'd.sadykova@octopod.ru',
|
'd.sadykova@octopod.ru',
|
||||||
'n.yurchenko@id-east.ru'
|
'n.yurchenko@id-east.ru'
|
||||||
)
|
)
|
||||||
and a.confirmed_at is not null
|
and a.confirmed_at is not null
|
||||||
''')
|
''')
|
||||||
return namedtuplefetchall(cursor)
|
return namedtuplefetchall(cursor)
|
||||||
|
|
||||||
|
|
@ -32,7 +32,12 @@ class Command(BaseCommand):
|
||||||
objects.append(User(email=a.email,
|
objects.append(User(email=a.email,
|
||||||
unconfirmed_email=False,
|
unconfirmed_email=False,
|
||||||
email_confirmed=True,
|
email_confirmed=True,
|
||||||
old_id=a.account_id
|
old_id=a.account_id,
|
||||||
|
password='bcrypt$'+a.encrypted_password
|
||||||
))
|
))
|
||||||
|
else:
|
||||||
|
user = User.objects.filter(Q(email=a.email) | Q(old_id=a.account_id))
|
||||||
|
user.update(password='bcrypt$'+a.encrypted_password)
|
||||||
|
|
||||||
User.objects.bulk_create(objects)
|
User.objects.bulk_create(objects)
|
||||||
self.stdout.write(self.style.WARNING(f'Created accounts objects.'))
|
self.stdout.write(self.style.WARNING(f'Created accounts objects.'))
|
||||||
Loading…
Reference in New Issue
Block a user