Exemplo n.º 1
0
def signup():
    firstName = request.args.get("firstName")
    lastName = request.args.get("lastName")
    email = request.args.get("email")
    country = request.args.get("country")
    organization = request.args.get("organization")
    position = request.args.get("position")
    purpose = request.args.get("purpose")

    print "Inside signup method"

    g_recaptcha_response = request.args.get("g-recaptcha-response")

    print "Captcha response: ", g_recaptcha_response
    remote_ip = request.remote_addr

    data = {"secret": "6LfyNUEUAAAAAJrb1GA0Pski-Gsvs9CP-yxFpVuE", "response": g_recaptcha_response}

    res = requests.post("https://www.google.com/recaptcha/api/siteverify", data=json.dumps(data))

    mongoClient = __get_mongo_connection()
    try:
        ret_value = json.loads(res.content)
        if firstName == "" or lastName == "" or email == "" or country == "" or organization == "" or position == "" or purpose == "":
            raise Exception("Empty field not acceptable")
        print ret_value['success']
        if g_recaptcha_response == "":
            raise Exception("Captcha Verification Failed")

        apiKey = add_user(firstName,lastName,email, country, organization, position, purpose,mongoClient.event_scrape)
        send_api_key(apiKey, mongoClient.event_scrape)

        return app.send_static_file('success.html')
    except:
        return app.send_static_file('error.html')
Exemplo n.º 2
0
def signup():
    firstName = request.args.get("firstName")
    lastName = request.args.get("lastName")
    email = request.args.get("email")
    country = request.args.get("country")
    organization = request.args.get("organization")
    position = request.args.get("position")
    purpose = request.args.get("purpose")

    print "Inside signup method"

    g_recaptcha_response = request.args.get("g-recaptcha-response")

    print "Captcha response: ", g_recaptcha_response
    remote_ip = request.remote_addr

    data = {"secret": "6LfyNUEUAAAAAJrb1GA0Pski-Gsvs9CP-yxFpVuE", "response": g_recaptcha_response}

    res = requests.post("https://www.google.com/recaptcha/api/siteverify", data=json.dumps(data))

    mongoClient = __get_mongo_connection()
    try:
        ret_value = json.loads(res.content)
        if firstName == "" or lastName == "" or email == "" or country == "" or organization == "" or position == "" or purpose == "":
            raise Exception("Empty field not acceptable")
        print ret_value['success']
        if g_recaptcha_response == "":
            raise Exception("Captcha Verification Failed")

        apiKey = add_user(firstName,lastName,email, country, organization, position, purpose,mongoClient.event_scrape)
        send_api_key(apiKey, mongoClient.event_scrape)

        return app.send_static_file('success.html')
    except:
        return app.send_static_file('error.html')