forked from shaba/openuds
* Fixed get name from authCallback
* added convenient "comments" to some parts * Fixed login, to cicly session only when logged in
This commit is contained in:
parent
d8eb440b34
commit
1936a02cf7
@ -64,6 +64,7 @@ class Environment(object):
|
||||
'''
|
||||
Method to acces the cache of the environment.
|
||||
@return: a referente to a Cache instance
|
||||
:rtype uds.core.util.Cache.Cache
|
||||
'''
|
||||
return self._cache
|
||||
|
||||
@ -187,6 +188,7 @@ class Environmentable(object):
|
||||
|
||||
Returns:
|
||||
Cache for the object
|
||||
:rtype uds.core.util.Cache.Cache
|
||||
'''
|
||||
return self._env.cache
|
||||
|
||||
|
@ -53,7 +53,7 @@ from uds.models import User
|
||||
import logging
|
||||
import six
|
||||
|
||||
__updated__ = '2017-11-22'
|
||||
__updated__ = '2018-06-27'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
authLogger = logging.getLogger('authLog')
|
||||
|
@ -48,7 +48,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2018-03-05'
|
||||
__updated__ = '2018-06-27'
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
@ -138,9 +138,9 @@ class Authenticator(ManagedObjectModel, TaggingMixin):
|
||||
|
||||
|
||||
'''
|
||||
realName = realName if realName is None else username
|
||||
realName = realName if realName else username
|
||||
user, _ = self.users.get_or_create(name=username, defaults={'real_name': realName, 'last_access': NEVER, 'state': State.ACTIVE})
|
||||
if user.real_name.strip() == '' and realName != user.real_name:
|
||||
if (user.real_name.strip() == '' or user.name.strip() == user.real_name.strip()) and realName != user.real_name:
|
||||
user.real_name = realName
|
||||
user.save()
|
||||
|
||||
|
@ -57,8 +57,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__updated__ = '2016-11-22'
|
||||
__updated__ = '2018-06-27'
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
@ -75,6 +74,8 @@ def authCallback(request, authName):
|
||||
authenticator = Authenticator.objects.get(name=authName)
|
||||
params = request.GET.copy()
|
||||
params.update(request.POST)
|
||||
logger.debug('Request session:%s -> %s, %s', request.ip, request.session.keys(), request.session.session_key)
|
||||
|
||||
params['_request'] = request
|
||||
# params['_session'] = request.session
|
||||
# params['_user'] = request.user
|
||||
|
@ -50,7 +50,8 @@ import uds.web.errors as errors
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
__updated__ = '2017-06-01'
|
||||
__updated__ = '2018-06-27'
|
||||
|
||||
|
||||
# Allow cross-domain login
|
||||
# @csrf_exempt
|
||||
@ -84,7 +85,6 @@ def login(request, tag=None):
|
||||
if 'uds' not in request.COOKIES:
|
||||
logger.debug('Request does not have uds cookie')
|
||||
return errors.errorView(request, errors.COOKIES_NEEDED) # We need cookies to keep session data
|
||||
request.session.cycle_key()
|
||||
form = LoginForm(request.POST, tag=tag)
|
||||
if form.is_valid():
|
||||
os = request.os
|
||||
@ -119,6 +119,8 @@ def login(request, tag=None):
|
||||
form.add_error(None, ugettext('Invalid credentials'))
|
||||
authLogLogin(request, authenticator, userName, 'Invalid credentials')
|
||||
else:
|
||||
request.session.cycle_key()
|
||||
|
||||
logger.debug('User {} has logged in'.format(userName))
|
||||
cache.remove(cacheKey) # Valid login, remove cached tries
|
||||
response = HttpResponseRedirect(reverse('uds.web.views.index'))
|
||||
|
Loading…
Reference in New Issue
Block a user