def account_create(request): """Create an account""" account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") new_account, create_p = Account.objects.get_or_create(email=urllib.unquote(account_id)) if create_p: """ generate a secondary secret or not? Requestor can say no. trust model makes sense: the admin app requestor only decides whether or not they control the additional interaction or if it's not necessary. They never see the primary secret. """ new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = request.POST.get('contact_email', account_id) new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "0") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() #SZ: if password and len(password) > 0: if primary_secret_p: new_account.generate_secrets(secondary_secret_p = secondary_secret_p) new_account.send_secret() return render_template('account', {'account' : new_account}, type='xml')
def account_send_newuser(request): contact_email = request.POST.get('contact_email', None) if not contact_email or not utils.is_valid_email(contact_email): return HttpResponseBadRequest("Contact email not valid") sendMail( [contact_email], '*****@*****.**', 'Register to iMC portal', 'Hello, please register to iMC portal in link https://www.iphr.care. A user asked to share his health information with you.', []) return DONE
def account_create(request): """Create an account""" account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") new_account, create_p = Account.objects.get_or_create( email=urllib.unquote(account_id)) if create_p: """ generate a secondary secret or not? Requestor can say no. trust model makes sense: the admin app requestor only decides whether or not they control the additional interaction or if it's not necessary. They never see the primary secret. """ new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = request.POST.get('contact_email', account_id) new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "0") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() #SZ: if password and len(password) > 0: if primary_secret_p: new_account.generate_secrets(secondary_secret_p=secondary_secret_p) new_account.send_secret() return render_template('account', {'account': new_account}, type='xml')
def account_create(request): """ Create a new account, and send out initialization emails. request.POST holds the creation arguments. Required Parameters: * *account_id*: an identifier for the new address. Must be formatted as an email address. Optional Parameters: * *full_name*: The full name to associate with the account. Defaults to the empty string. * *contact_email*: A valid email at which the account holder can be reached. Defaults to the *account_id* parameter. * *primary_secret_p*: ``0`` or ``1``. Whether or not to associate a primary secret with the account. Defaults to ``1``. * *secondary_secret_p*: ``0`` or ``1``. Whether or not to associate a secondary secret with the account. Defaults to ``0``. After creating the new account, this call generates secrets for it, and then emails the user (at *contact_email*) with their activation link, which contains the primary secret. This call will return :http:statuscode:`200` with info about the new account on success, :http:statuscode:`400` if *account_id* isn't provided or isn't a valid email address, or if an account already exists with an id matching *account_id*. """ account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") contact_email = request.POST.get('contact_email', account_id) if not contact_email or not utils.is_valid_email(contact_email): return HttpResponseBadRequest("Contact email not valid") new_account, create_p = Account.objects.get_or_create(email=urllib.unquote(account_id).lower().strip()) if create_p: # generate a secondary secret or not? Requestor can say no. # trust model makes sense: the admin app requestor only decides whether or not # they control the additional interaction or if it's not necessary. They never # see the primary secret. new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = contact_email new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "1") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() if primary_secret_p: new_account.generate_secrets(secondary_secret_p = secondary_secret_p) try: new_account.send_secret() except Exception, e: logging.exception(e)
def account_create(request): """ Create a new account, and send out initialization emails. request.POST holds the creation arguments. Required Parameters: * *account_id*: an identifier for the new address. Must be formatted as an email address. Optional Parameters: * *full_name*: The full name to associate with the account. Defaults to the empty string. * *contact_email*: A valid email at which the account holder can be reached. Defaults to the *account_id* parameter. * *primary_secret_p*: ``0`` or ``1``. Whether or not to associate a primary secret with the account. Defaults to ``0``. * *secondary_secret_p*: ``0`` or ``1``. Whether or not to associate a secondary secret with the account. Defaults to ``1``. After creating the new account, this call generates secrets for it, and then emails the user (at *contact_email*) with their activation link, which contains the primary secret. This call will return :http:statuscode:`200` with info about the new account on success, :http:statuscode:`400` if *account_id* isn't provided or isn't a valid email address, or if an account already exists with an id matching *account_id*. """ account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") new_account, create_p = Account.objects.get_or_create(email=urllib.unquote(account_id).lower().strip()) if create_p: # generate a secondary secret or not? Requestor can say no. # trust model makes sense: the admin app requestor only decides whether or not # they control the additional interaction or if it's not necessary. They never # see the primary secret. new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = request.POST.get('contact_email', account_id) new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "0") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() if primary_secret_p: new_account.generate_secrets(secondary_secret_p = secondary_secret_p) try: new_account.send_secret() except Exception, e: logging.exception(e)
def account_create(request): """ Create a new account, and send out initialization emails. ``request.POST`` holds the creation arguments. In Demo Mode, this call automatically creates new records for the account, populated with sample data. See :doc:`/sample-data` for details. Required Parameters: * *account_id*: an identifier for the new address. Must be formatted as an email address. Optional Parameters: * *full_name*: The full name to associate with the account. Defaults to the empty string. * *contact_email*: A valid email at which the account holder can be reached. Defaults to the *account_id* parameter. * *primary_secret_p*: ``0`` or ``1``. Whether or not to associate a primary secret with the account. Defaults to ``1``. * *secondary_secret_p*: ``0`` or ``1``. Whether or not to associate a secondary secret with the account. Defaults to ``0``. After creating the new account, this call generates secrets for it, and then emails the user (at *contact_email*) with their activation link, which contains the primary secret. This call will return :http:statuscode:`200` with info about the new account on success, :http:statuscode:`400` if *account_id* isn't provided or isn't a valid email address, or if an account already exists with an id matching *account_id*. """ account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") contact_email = request.POST.get('contact_email', account_id) if not contact_email or not utils.is_valid_email(contact_email): return HttpResponseBadRequest("Contact email not valid") new_account, create_p = Account.objects.get_or_create( email=urllib.unquote(account_id).lower().strip()) if create_p: # generate a secondary secret or not? Requestor can say no. # trust model makes sense: the admin app requestor only decides whether or not # they control the additional interaction or if it's not necessary. They never # see the primary secret. new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = contact_email new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "1") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() if settings.DEMO_MODE: loader = IndivoDataLoader(request.principal) # Create new records for the account, populated by sample data. for record_label, data_profile in settings.DEMO_PROFILES.iteritems( ): # Create the record record = Record.objects.create(creator=request.principal, label=record_label, owner=new_account) try: # Load the data: no transactions, as we're already managing them above loader.load_profile(record, data_profile, transaction=False) except Exception, e: # Something went wrong: roll everything back and fail logging.exception(e) raise if primary_secret_p: new_account.generate_secrets(secondary_secret_p=secondary_secret_p) try: new_account.send_secret() except Exception, e: logging.exception(e)
def account_create(request): """ Create a new account, and send out initialization emails. ``request.POST`` holds the creation arguments. In Demo Mode, this call automatically creates new records for the account, populated with sample data. See :doc:`/sample-data` for details. Required Parameters: * *account_id*: an identifier for the new address. Must be formatted as an email address. Optional Parameters: * *full_name*: The full name to associate with the account. Defaults to the empty string. * *contact_email*: A valid email at which the account holder can be reached. Defaults to the *account_id* parameter. * *primary_secret_p*: ``0`` or ``1``. Whether or not to associate a primary secret with the account. Defaults to ``1``. * *secondary_secret_p*: ``0`` or ``1``. Whether or not to associate a secondary secret with the account. Defaults to ``0``. After creating the new account, this call generates secrets for it, and then emails the user (at *contact_email*) with their activation link, which contains the primary secret. This call will return :http:statuscode:`200` with info about the new account on success, :http:statuscode:`400` if *account_id* isn't provided or isn't a valid email address, or if an account already exists with an id matching *account_id*. """ account_id = request.POST.get('account_id', None) if not account_id or not utils.is_valid_email(account_id): return HttpResponseBadRequest("Account ID not valid") contact_email = request.POST.get('contact_email', account_id) if not contact_email or not utils.is_valid_email(contact_email): return HttpResponseBadRequest("Contact email not valid") new_account, create_p = Account.objects.get_or_create(email=urllib.unquote(account_id).lower().strip()) if create_p: # generate a secondary secret or not? Requestor can say no. # trust model makes sense: the admin app requestor only decides whether or not # they control the additional interaction or if it's not necessary. They never # see the primary secret. new_account.full_name = request.POST.get('full_name', '') new_account.contact_email = contact_email new_account.creator = request.principal password = request.POST.get('password', None) primary_secret_p = (request.POST.get('primary_secret_p', "1") == "1") secondary_secret_p = (request.POST.get('secondary_secret_p', "0") == "1") # we don't allow setting the password here anymore new_account.save() if settings.DEMO_MODE: loader = IndivoDataLoader(request.principal) # Create new records for the account, populated by sample data. for record_label, data_profile in settings.DEMO_PROFILES.iteritems(): # Create the record record = Record.objects.create(creator=request.principal, label=record_label, owner=new_account) try: # Load the data: no transactions, as we're already managing them above loader.load_profile(record, data_profile, transaction=False) except Exception, e: # Something went wrong: roll everything back and fail logging.exception(e) raise if primary_secret_p: new_account.generate_secrets(secondary_secret_p = secondary_secret_p) try: new_account.send_secret() except Exception, e: logging.exception(e)