# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-11 17:28
from __future__ import unicode_literals

from django.db import migrations


def forwards_func(apps, schema_editor):
    User = apps.get_model('auth', 'User')

    old_password_patterns = (
        'sha1$',
        # RTD's production database doesn't have any of these
        # but they are included for completeness
        'md5$',
        'crypt$',
    )
    for pattern in old_password_patterns:
        users = User.objects.filter(password__startswith=pattern)
        for user in users:
            user.set_unusable_password()
            user.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0004_ad-opt-out'),
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.RunPython(forwards_func),
    ]

# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-11 17:28
from __future__ import unicode_literals

from django.db import migrations
from django.contrib.auth.hashers import make_password


def forwards_func(apps, schema_editor):
    User = apps.get_model('auth', 'User')

    old_password_patterns = (
        'sha1$',
        # RTD's production database doesn't have any of these
        # but they are included for completeness
        'md5$',
        'crypt$',
    )
    for pattern in old_password_patterns:
        users = User.objects.filter(password__startswith=pattern)
        for user in users:
            user.password = make_password(None)
            user.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0004_ad-opt-out'),
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.RunPython(forwards_func),
    ]

Migrate old passwords without "set_unusable_password"
Migrate old passwords without "set_unusable_password"
