|
1 |
#
|
|
2 |
# Copyright (C) 2010-2019 Entr'ouvert
|
|
3 |
#
|
|
4 |
# This program is free software: you can redistribute it and/or modify it
|
|
5 |
# under the terms of the GNU Affero General Public License as published
|
|
6 |
# by the Free Software Foundation, either version 3 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU Affero General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU Affero General Public License
|
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
|
1 |
17 |
from __future__ import unicode_literals
|
2 |
18 |
|
3 |
19 |
from django.db import models
|
4 |
20 |
from django.contrib.auth import get_user_model
|
5 |
21 |
from django.contrib.auth.backends import ModelBackend
|
|
22 |
from django.utils import six
|
6 |
23 |
|
7 |
24 |
from .. import app_settings
|
8 |
25 |
from authentic2.user_login_failure import user_login_success, user_login_failure
|
... | ... | |
39 |
56 |
if app_settings.REALMS:
|
40 |
57 |
for realm, desc in app_settings.REALMS:
|
41 |
58 |
queries.append(models.Q(
|
42 |
|
**{username_field: upn(username, realm)}))
|
|
59 |
**{username_field: upn(username, realm)}))
|
43 |
60 |
else:
|
44 |
61 |
queries.append(models.Q(**{username_field: upn(username, realm)}))
|
45 |
|
return reduce(models.Q.__or__, queries)
|
|
62 |
return six.moves.reduce(models.Q.__or__, queries)
|
46 |
63 |
|
47 |
64 |
def must_reset_password(self, user):
|
48 |
65 |
from .. import models
|
49 |
|
-
|