# Path: src/librement/account/models.py
# class Email(models.Model):
#     user = models.ForeignKey('auth.User', related_name='emails')
# 
#     email = models.EmailField(unique=True)
# 
#     def __unicode__(self):
#         return u"%s" % self.email


from django.contrib.auth.backends import ModelBackend
from .models import Email
# Copyright 2012 The Librement Developers
#
# See the AUTHORS file at the top-level directory of this distribution
# and at http://librement.net/copyright/
#
# This file is part of Librement. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this distribution
# and at http://librement.net/license/. No part of Librement, including
# this file, may be copied, modified, propagated, or distributed except
# according to the terms contained in the LICENSE file.



class LibrementBackend(ModelBackend):
    def authenticate(self, email=None, password=None):
        try:

# Path: src/librement/account/models.py
# class Email(models.Model):
#     user = models.ForeignKey('auth.User', related_name='emails')
# 
#     email = models.EmailField(unique=True)
# 
#     def __unicode__(self):
#         return u"%s" % self.email


# Path: src/librement/account/backends.py
from django.contrib.auth.backends import ModelBackend
from .models import Email

# Copyright 2012 The Librement Developers
#
# See the AUTHORS file at the top-level directory of this distribution
# and at http://librement.net/copyright/
#
# This file is part of Librement. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this distribution
# and at http://librement.net/license/. No part of Librement, including
# this file, may be copied, modified, propagated, or distributed except
# according to the terms contained in the LICENSE file.



class LibrementBackend(ModelBackend):
    def authenticate(self, email=None, password=None):
        try:

            email = Email.objects.get(email__iexact=email)