atomic user creation/notification

master
vilmibm 2019-10-11 22:53:39 +00:00
parent 4e3977edd2
commit 5220d9bfad
1 changed files with 7 additions and 3 deletions

View File

@ -246,9 +246,13 @@ def on_townie_pre_save(sender, instance, **kwargs):
# See if we need to create the user on disk.
if existing.unreviewed and instance.accepted:
logger.info('Creating user {} on disk.'.format(instance.username))
try:
instance.create_on_disk()
instance.send_welcome_email()
instance.write_authorized_keys()
except Exception as e:
logger.error('Failed syncing user {} to disk: {}'.format(instance.username, e)
else:
instance.send_welcome_email()
return
else:
# This user state transition is currently undefined. In the future, we can check for things