def _do_registration(form, send_sms=True, send_email=True, organisation_id=None): if user_api_client.is_email_already_in_use(form.email_address.data): user = user_api_client.get_user_by_email(form.email_address.data) if send_email: user_api_client.send_already_registered_email(user.id, user.email_address) session['expiry_date'] = str(datetime.utcnow() + timedelta(hours=1)) session['user_details'] = {"email": user.email_address, "id": user.id} else: user = user_api_client.register_user(form.name.data, form.email_address.data, form.mobile_number.data or None, form.password.data, form.auth_type.data) if send_email: user_api_client.send_verify_email(user.id, user.email_address) if send_sms: user_api_client.send_verify_code(user.id, 'sms', user.mobile_number) if form.research_consent.data: user_api_client.send_research_consent_email(user.id) session['expiry_date'] = str(datetime.utcnow() + timedelta(hours=1)) session['user_details'] = {"email": user.email_address, "id": user.id} if organisation_id: session['organisation_id'] = organisation_id
def _is_email_already_in_use(email): return user_api_client.is_email_already_in_use(email)