Skip to content

onlineweb apps authentication_new

Nils Herde edited this page Mar 2, 2018 · 1 revision

Authentication includes a custom user object which is build on django's AbstractUser: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-django-s-default-user


Email problems

During the first months of ow4, a lot of problems were discovered with the user emails. Most of these are now straightened out, but some users are still found to be without emails as late as end of january 2014.

In order to check which users are lacking emails and how to fix it, use these commands in the django shell:

1 Find all users without an email

In [58]: users = User.objects.filter(email = '')

If this returns an empty queryset, all users have a primary email registered to them stored in user.email. Whether this email is actually valid is another matter, but the rest of these commands will not help you!

Display the users and the emails registered to their account:

In [59]: for user in users:
   ....:  print user,
   ....:  print user.get_emails()
   ....:
Ola Nordmann [<Email: [email protected]>]
Kari Nordmann [<Email: [email protected]>]
...

If a user is displayed here without an email following, it means that users has an account with not registered emails, which should be impossible. The only way this should ever happen is if the user is not created through due process (registration), like through manage.py or in the admin interface.

In the case every user listed with the above command has at least one email attached to it, you can run the following to populate the email field for each user:

In [60]: for user in users:
   ....:  email = user.get_email()
   ....:  email.save()
   ....:

Then verify that there are no users without email left by fetching from the DB again

In [62]: User.objects.filter(email = '')

Out[62]: []