Example #1
0
def create(cid, email):
    """
    /api/contacts/{cid}/emails
    Create new contact email
    
    :param email: email information
    :return:      matching email
    """
    emailAddress = email.get("email", None)

    if emailAddress is None:
        abort(406, "Email field must not be empty")

    model = Email.create(**{
        'email': emailAddress,
        'contact_id': cid
    })

    return make_response(f"{emailAddress} successfully created for contact {cid}", 201)
Example #2
0
 def handle_register(self):
     email = self.request.get('email')
     passwd = self.request.get('passwd')
     if not email or not passwd:
         return False
     entity = Email.create(email, passwd)
     if not entity:
         return False, '%s has been registered' % email
     url = UrlUtil.urlencode('/confirm_register', {
         'key': entity.key.urlsafe(),
         'passwd': passwd
     })
     self.send_email(
         email, 'Register confirm mail', """Please click below url to login:
             %s
         """ % ('https://selfcontrolboard.appspot.com' + url))
     if self.is_test_env():
         return True, 'http://localhost:8080' + url
     else:
         return True, 'ok'