Commit e7166867 authored by David Seaward's avatar David Seaward

validate user email before generating certificate

parent 8f0b8684
import django.contrib.auth
import paramiko
from celery import shared_task
from celery.utils.log import get_task_logger
......@@ -132,6 +133,22 @@ def update_limit_woo1(ssh, credit):
service=external_bundle.service,
)
user = django.contrib.auth.get_user_model().objects.get(
username=username
)
# set user email if missing
credit_has_email = not (credit.additional_data is None or credit.additional_data == "")
user_has_email = not (user.email is None or user.email == "")
if user_has_email:
pass
elif credit_has_email:
user.email = credit.additional_data
user.save()
else:
raise Exception("No email address for credit.")
# FIXME: should not simply activate an inactive service
credit_days = int(external_bundle.time_credit * credit.quantity)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment