1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Fixed login fail messages for django 1.9

This commit is contained in:
Adolfo Gómez García 2016-02-19 08:37:22 +01:00
parent 56ac8aece9
commit f9226e7deb
4 changed files with 7 additions and 21 deletions

View File

@ -105,7 +105,7 @@ class ServicesPools(ModelHandler):
'user_services_count': item.userServices.count(),
'restrained': item.isRestrained(),
'show_transports': item.show_transports,
'allowAccessByDefault': ALLOW if item.fallbackAccessAllow is True else DENY,
'allowAccessByDefault': item.fallbackAccess,
'permission': permissions.getEffectivePermission(self._user, item),
'info': Services.serviceInfo(item.service),
}

View File

@ -69,12 +69,13 @@ class UDSAppConfig(AppConfig):
# We have to take care with this, because it's supposed to be executed
# with ANY command from manage.
logger.debug('Initializing app (ready) ***************')
# Now, ensures that all dynamic elements are loadad and present
from . import services # to make sure that the packages are initialized at this point
from . import auths # To make sure that the packages are initialized at this point
from . import osmanagers # To make sure that packages are initialized at this point
from . import transports # To make sure that packages are initialized at this point
from . import dispatchers
from . import models
from . import dispatchers # Ensure all dischatchers all also available
from . import plugins # To make sure plugins are loaded on memory
from . import REST # To make sure REST initializes all what it needs

View File

@ -36,7 +36,6 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from django import forms
from django.utils.safestring import mark_safe
from django.forms.forms import NON_FIELD_ERRORS
# from django.forms.util import ErrorDict
from uds.models import Authenticator
import logging
@ -57,20 +56,6 @@ class CustomSelect(forms.Select):
res += '</select>'
return mark_safe('<div class="form-group"{0}><label>'.format(visible) + unicode(_('authenticator')) + '</label>' + res + '</div>')
# class BaseForm(forms.Form):
#
# def __init__(self, *args, **kwargs):
# super(BaseForm, self).__init__(*args, **kwargs)
#
# def add_form_error(self, message):
# if not self._errors:
# self._errors = ErrorDict()
# if NON_FIELD_ERRORS not in self._errors:
# self._errors[NON_FIELD_ERRORS] = self.error_class()
# self._errors[NON_FIELD_ERRORS].append(message)
class LoginForm(forms.Form):
user = forms.CharField(label=_('Username'), max_length=64, widget=forms.TextInput())
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput(attrs={'title': _('Password')}), required=False)

View File

@ -49,7 +49,7 @@ import uds.web.errors as errors
import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-11-16'
__updated__ = '2016-02-19'
def login(request, tag=None):
@ -98,7 +98,7 @@ def login(request, tag=None):
if tries is None:
tries = 0
if authenticator.getInstance().blockUserOnLoginFailures is True and tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt():
form.add_form_error('Too many authentication errors. User temporarily blocked.')
form.add_error(None, 'Too many authentication errors. User temporarily blocked.')
authLogLogin(request, authenticator, userName, 'Temporarily blocked')
else:
password = form.cleaned_data['password']
@ -112,7 +112,7 @@ def login(request, tag=None):
logger.debug("Invalid credentials for user {0}".format(userName))
tries += 1
cache.put(cacheKey, tries, GlobalConfig.LOGIN_BLOCK.getInt())
form.add_form_error(ugettext('Invalid credentials'))
form.add_error(None, ugettext('Invalid credentials'))
authLogLogin(request, authenticator, userName, 'Invalid credentials')
else:
logger.debug('User {} has logged in'.format(userName))