app_settings: rename ACCEPT_EMAIL_AUTHENTICATION to A2_ACCEPT_EMAIL_AUTHENTICATION (fixes #23514)
This commit is contained in:
parent
47d324c34e
commit
b140cb2612
|
@ -30,11 +30,6 @@ class AppSettings(object):
|
|||
self._settings = settings
|
||||
return self._settings
|
||||
|
||||
@property
|
||||
def ACCEPT_EMAIL_AUTHENTICATION(self):
|
||||
return getattr(self.settings,
|
||||
'A2_ACCEPT_EMAIL_AUTHENTICATION', True)
|
||||
|
||||
@property
|
||||
def REALMS(self):
|
||||
realms = {}
|
||||
|
@ -194,6 +189,8 @@ default_settings = dict(
|
|||
definition='Set a random password on request to reset the password from the front-office'),
|
||||
A2_ACCOUNTS_URL=Setting(default=None, definition='IdP has no account page, redirect to this one.'),
|
||||
A2_CACHE_ENABLED=Setting(default=True, definition='Disable all cache decorators for testing purpose.'),
|
||||
A2_ACCEPT_EMAIL_AUTHENTICATION=Setting(default=True, definition='Enable authentication by email'),
|
||||
|
||||
)
|
||||
|
||||
app_settings = AppSettings(default_settings)
|
||||
|
|
|
@ -21,7 +21,7 @@ class LoginPasswordBackend(object):
|
|||
is_post = request.method == 'POST' and self.submit_name in request.POST
|
||||
data = request.POST if is_post else None
|
||||
form = forms.AuthenticationForm(request=request, data=data)
|
||||
if app_settings.ACCEPT_EMAIL_AUTHENTICATION:
|
||||
if app_settings.A2_ACCEPT_EMAIL_AUTHENTICATION:
|
||||
form.fields['username'].label = _('Username or email')
|
||||
if app_settings.A2_USERNAME_LABEL:
|
||||
form.fields['username'].label = app_settings.A2_USERNAME_LABEL
|
||||
|
|
|
@ -27,7 +27,7 @@ class ModelBackend(ModelBackend):
|
|||
username_field = 'username'
|
||||
queries = []
|
||||
try:
|
||||
if app_settings.ACCEPT_EMAIL_AUTHENTICATION \
|
||||
if app_settings.A2_ACCEPT_EMAIL_AUTHENTICATION \
|
||||
and UserModel._meta.get_field('email'):
|
||||
queries.append(models.Q(**{'email__iexact': username}))
|
||||
except models.FieldDoesNotExist:
|
||||
|
|
Loading…
Reference in New Issue