# Path: account/conf.py
# def load_path_attr(path):
#     def configure_deletion_mark_callback(self, value):
#     def configure_deletion_expunge_callback(self, value):
#     def configure_hookset(self, value):
# class AccountAppConf(AppConf):
#     OPEN_SIGNUP = True
#     LOGIN_URL = "account_login"
#     SIGNUP_REDIRECT_URL = "/"
#     LOGIN_REDIRECT_URL = "/"
#     LOGOUT_REDIRECT_URL = "/"
#     PASSWORD_CHANGE_REDIRECT_URL = "account_password"
#     PASSWORD_RESET_REDIRECT_URL = "account_login"
#     REMEMBER_ME_EXPIRY = 60 * 60 * 24 * 365 * 10
#     USER_DISPLAY = lambda user: user.username  # flake8: noqa
#     CREATE_ON_SAVE = True
#     EMAIL_UNIQUE = True
#     EMAIL_CONFIRMATION_REQUIRED = False
#     EMAIL_CONFIRMATION_EMAIL = True
#     EMAIL_CONFIRMATION_EXPIRE_DAYS = 3
#     EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "account_login"
#     EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = None
#     EMAIL_CONFIRMATION_URL = "account_confirm_email"
#     SETTINGS_REDIRECT_URL = "account_settings"
#     NOTIFY_ON_PASSWORD_CHANGE = True
#     DELETION_MARK_CALLBACK = "account.callbacks.account_delete_mark"
#     DELETION_EXPUNGE_CALLBACK = "account.callbacks.account_delete_expunge"
#     DELETION_EXPUNGE_HOURS = 48
#     HOOKSET = "account.hooks.AccountDefaultHookSet"
#     TIMEZONES = TIMEZONES
#     LANGUAGES = LANGUAGES
#     USE_AUTH_AUTHENTICATE = False
# 
# Path: account/models.py
# class EmailAddress(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     email = models.EmailField(max_length=254, unique=settings.ACCOUNT_EMAIL_UNIQUE)
#     verified = models.BooleanField(_("verified"), default=False)
#     primary = models.BooleanField(_("primary"), default=False)
# 
#     objects = EmailAddressManager()
# 
#     class Meta:
#         verbose_name = _("email address")
#         verbose_name_plural = _("email addresses")
#         if not settings.ACCOUNT_EMAIL_UNIQUE:
#             unique_together = [("user", "email")]
# 
#     def __str__(self):
#         return "{0} ({1})".format(self.email, self.user)
# 
#     def set_as_primary(self, conditional=False):
#         old_primary = EmailAddress.objects.get_primary(self.user)
#         if old_primary:
#             if conditional:
#                 return False
#             old_primary.primary = False
#             old_primary.save()
#         self.primary = True
#         self.save()
#         self.user.email = self.email
#         self.user.save()
#         return True
# 
#     def send_confirmation(self, **kwargs):
#         confirmation = EmailConfirmation.create(self)
#         confirmation.send(**kwargs)
#         return confirmation
# 
#     def change(self, new_email, confirm=True):
#         """
#         Given a new email address, change self and re-confirm.
#         """
#         with transaction.atomic():
#             self.user.email = new_email
#             self.user.save()
#             self.email = new_email
#             self.verified = False
#             self.save()
#             if confirm:
#                 self.send_confirmation()
# 
# Path: account/utils.py
# def get_user_lookup_kwargs(kwargs):
#     result = {}
#     username_field = getattr(get_user_model(), "USERNAME_FIELD", "username")
#     for key, value in kwargs.items():
#         result[key.format(username=username_field)] = value
#     return result


import re
    from collections import OrderedDict
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib import auth
from django.contrib.auth import get_user_model
from account.conf import settings
from account.hooks import hookset
from account.models import EmailAddress
from account.utils import get_user_lookup_kwargs
    password_new = forms.CharField(
            label=_("New Password"),
            widget=forms.PasswordInput(render_value=False)
    )
    password_new_confirm = forms.CharField(
            label=_("New Password (again)"),
            widget=forms.PasswordInput(render_value=False)
    )

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        super(ChangePasswordForm, self).__init__(*args, **kwargs)

    def clean_password_current(self):
        if not self.user.check_password(self.cleaned_data.get("password_current")):
            raise forms.ValidationError(_("Please type your current password."))
        return self.cleaned_data["password_current"]

    def clean_password_new_confirm(self):
        if "password_new" in self.cleaned_data and "password_new_confirm" in self.cleaned_data:
            if self.cleaned_data["password_new"] != self.cleaned_data["password_new_confirm"]:
                raise forms.ValidationError(_("You must type the same password each time."))
        return self.cleaned_data["password_new_confirm"]


class PasswordResetForm(forms.Form):
    email = forms.EmailField(label=_("Email"), required=True)

    def clean_email(self):
        value = self.cleaned_data["email"]

# Path: account/conf.py
# def load_path_attr(path):
#     def configure_deletion_mark_callback(self, value):
#     def configure_deletion_expunge_callback(self, value):
#     def configure_hookset(self, value):
# class AccountAppConf(AppConf):
#     OPEN_SIGNUP = True
#     LOGIN_URL = "account_login"
#     SIGNUP_REDIRECT_URL = "/"
#     LOGIN_REDIRECT_URL = "/"
#     LOGOUT_REDIRECT_URL = "/"
#     PASSWORD_CHANGE_REDIRECT_URL = "account_password"
#     PASSWORD_RESET_REDIRECT_URL = "account_login"
#     REMEMBER_ME_EXPIRY = 60 * 60 * 24 * 365 * 10
#     USER_DISPLAY = lambda user: user.username  # flake8: noqa
#     CREATE_ON_SAVE = True
#     EMAIL_UNIQUE = True
#     EMAIL_CONFIRMATION_REQUIRED = False
#     EMAIL_CONFIRMATION_EMAIL = True
#     EMAIL_CONFIRMATION_EXPIRE_DAYS = 3
#     EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "account_login"
#     EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = None
#     EMAIL_CONFIRMATION_URL = "account_confirm_email"
#     SETTINGS_REDIRECT_URL = "account_settings"
#     NOTIFY_ON_PASSWORD_CHANGE = True
#     DELETION_MARK_CALLBACK = "account.callbacks.account_delete_mark"
#     DELETION_EXPUNGE_CALLBACK = "account.callbacks.account_delete_expunge"
#     DELETION_EXPUNGE_HOURS = 48
#     HOOKSET = "account.hooks.AccountDefaultHookSet"
#     TIMEZONES = TIMEZONES
#     LANGUAGES = LANGUAGES
#     USE_AUTH_AUTHENTICATE = False
# 
# Path: account/models.py
# class EmailAddress(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     email = models.EmailField(max_length=254, unique=settings.ACCOUNT_EMAIL_UNIQUE)
#     verified = models.BooleanField(_("verified"), default=False)
#     primary = models.BooleanField(_("primary"), default=False)
# 
#     objects = EmailAddressManager()
# 
#     class Meta:
#         verbose_name = _("email address")
#         verbose_name_plural = _("email addresses")
#         if not settings.ACCOUNT_EMAIL_UNIQUE:
#             unique_together = [("user", "email")]
# 
#     def __str__(self):
#         return "{0} ({1})".format(self.email, self.user)
# 
#     def set_as_primary(self, conditional=False):
#         old_primary = EmailAddress.objects.get_primary(self.user)
#         if old_primary:
#             if conditional:
#                 return False
#             old_primary.primary = False
#             old_primary.save()
#         self.primary = True
#         self.save()
#         self.user.email = self.email
#         self.user.save()
#         return True
# 
#     def send_confirmation(self, **kwargs):
#         confirmation = EmailConfirmation.create(self)
#         confirmation.send(**kwargs)
#         return confirmation
# 
#     def change(self, new_email, confirm=True):
#         """
#         Given a new email address, change self and re-confirm.
#         """
#         with transaction.atomic():
#             self.user.email = new_email
#             self.user.save()
#             self.email = new_email
#             self.verified = False
#             self.save()
#             if confirm:
#                 self.send_confirmation()
# 
# Path: account/utils.py
# def get_user_lookup_kwargs(kwargs):
#     result = {}
#     username_field = getattr(get_user_model(), "USERNAME_FIELD", "username")
#     for key, value in kwargs.items():
#         result[key.format(username=username_field)] = value
#     return result


# Path: account/forms.py
import re
    from collections import OrderedDict
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib import auth
from django.contrib.auth import get_user_model
from account.conf import settings
from account.hooks import hookset
from account.models import EmailAddress
from account.utils import get_user_lookup_kwargs

    password_new = forms.CharField(
            label=_("New Password"),
            widget=forms.PasswordInput(render_value=False)
    )
    password_new_confirm = forms.CharField(
            label=_("New Password (again)"),
            widget=forms.PasswordInput(render_value=False)
    )

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        super(ChangePasswordForm, self).__init__(*args, **kwargs)

    def clean_password_current(self):
        if not self.user.check_password(self.cleaned_data.get("password_current")):
            raise forms.ValidationError(_("Please type your current password."))
        return self.cleaned_data["password_current"]

    def clean_password_new_confirm(self):
        if "password_new" in self.cleaned_data and "password_new_confirm" in self.cleaned_data:
            if self.cleaned_data["password_new"] != self.cleaned_data["password_new_confirm"]:
                raise forms.ValidationError(_("You must type the same password each time."))
        return self.cleaned_data["password_new_confirm"]


class PasswordResetForm(forms.Form):
    email = forms.EmailField(label=_("Email"), required=True)

    def clean_email(self):
        value = self.cleaned_data["email"]

        if not EmailAddress.objects.filter(email__iexact=value).exists():