Merge pull request #3400 from FinnStutzenstein/UserAutoupdate

Autoupdates on user login (fixes #3395, fixes #3392)
This commit is contained in:
Emanuel Schütze 2017-09-15 11:48:35 +02:00 committed by GitHub
commit 4565e7e4a6
7 changed files with 15 additions and 6 deletions

View File

@ -55,6 +55,8 @@ Users:
- Fixed compare of duplicated users while CSV user import [#3201].
- Added fast mass import for users [#3290].
- Removed OPTIONS request. All permissions are now provided on startup [#3306].
- Added option to enable updating the last_login field in the database. The
default is now disabled [#3400].
Core:
- No reload on logoff. OpenSlides is now a full single page

View File

@ -106,7 +106,6 @@ PASSWORD_HASHERS = [
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher', # MD5 is only used for initial passwords.
]
@ -143,3 +142,6 @@ CHANNEL_LAYERS = {
},
},
}
# Enable updating the last_login field for users on every login.
ENABLE_LAST_LOGIN_FIELD = False

View File

@ -1,4 +1,6 @@
from django.apps import AppConfig
from django.conf import settings
from django.contrib.auth.signals import user_logged_in
from ..utils.collection import Collection
from ..utils.projector import register_projector_elements
@ -32,6 +34,10 @@ class UsersAppConfig(AppConfig):
get_permission_change_data,
dispatch_uid='users_get_permission_change_data')
# Disconnect the last_login signal
if not settings.ENABLE_LAST_LOGIN_FIELD:
user_logged_in.disconnect(dispatch_uid='update_last_login')
# Register viewsets.
router.register(self.get_model('User').get_collection_string(), UserViewSet)
router.register(self.get_model('Group').get_collection_string(), GroupViewSet)

View File

@ -70,7 +70,7 @@ class UserManager(BaseUserManager):
username='admin',
defaults={'last_name': 'Administrator'})
admin.default_password = 'admin'
admin.password = make_password(admin.default_password, '', 'md5')
admin.password = make_password(admin.default_password)
admin.save()
admin.groups.add(staff)
return created

View File

@ -80,7 +80,7 @@ class UserFullSerializer(ModelSerializer):
# Prepare setup password.
if not validated_data.get('default_password'):
validated_data['default_password'] = User.objects.generate_password()
validated_data['password'] = make_password(validated_data['default_password'], '', 'md5')
validated_data['password'] = make_password(validated_data['default_password'])
return validated_data
def create(self, validated_data):

View File

@ -141,7 +141,6 @@ MEDIA_ROOT = os.path.join(OPENSLIDES_USER_DATA_PATH, 'media', '')
# https://docs.djangoproject.com/en/1.10/topics/auth/passwords/#module-django.contrib.auth.password_validation
# AUTH_PASSWORD_VALIDATORS = []
# Customization of OpenSlides apps
MOTION_IDENTIFIER_MIN_DIGITS = 1

View File

@ -193,7 +193,7 @@ class Command(BaseCommand):
if staff_users is not None and staff_users > 0:
self.stdout.write('Start creating {} staff users ...'.format(staff_users))
group_staff = Group.objects.get(name='Staff')
hashed_password = make_password(PASSWORD, '', 'md5')
hashed_password = make_password(PASSWORD)
current_users = list(User.objects.values_list('id', flat=True))
new_users = []
for i in range(staff_users):
@ -223,7 +223,7 @@ class Command(BaseCommand):
default_users = options['users'][1]
if default_users is not None and default_users > 0:
self.stdout.write('Start creating {} default users ...'.format(default_users))
hashed_password = make_password(PASSWORD, '', 'md5')
hashed_password = make_password(PASSWORD)
new_users = []
for i in range(default_users):
new_users.append(User(