def verify_email(environ, start_response): config = get_config() params = dict(parse_qsl(environ.get('QUERY_STRING', ''))) try: filename = config.get('submit_email', params['product'] + '_filename') except (KeyError, ConfigParser.NoOptionError): return send_simple_response(start_response, 400, 'Unknown product') email = params.get('email', '') signature = params.get('signature', '') if sign(config, email) != signature: return send_simple_response( start_response, 403, 'Invalid signature in verification request.') with open(filename, 'ab', 0) as file: fcntl.lockf(file, fcntl.LOCK_EX) try: print >> file, email finally: fcntl.lockf(file, fcntl.LOCK_UN) location = config.get('submit_email', 'successful_verification_redirect_location') location = location.format(lang=quote(params.get('lang') or 'en', '')) start_response('303 See Other', [('Location', location)]) return []
def submit_email(environ, start_response, data): email = data.get('email', '').strip() try: email = encode_email_address(email) except ValueError: return send_simple_response( start_response, 400, 'Please enter a valid email address.' ) config = get_config() params = [('email', email), ('signature', sign(config, email))] lang = data.get('lang') if lang: params.append(('lang', lang)) sendMail( config.get('submit_email', 'verification_email_template'), { 'recipient': email, 'verification_url': '%s?%s' % ( urljoin(wsgiref.util.application_uri(environ), VERIFICATION_PATH), urlencode(params) ) } ) return send_simple_response( start_response, 200, 'A confirmation email has been sent. Please check ' 'your email and click the confirmation link.' )
def verify_email(environ, start_response): config = get_config() params = dict(parse_qsl(environ.get('QUERY_STRING', ''))) try: filename = config.get('submit_email', params['product'] + '_filename') except (KeyError, ConfigParser.NoOptionError): return send_simple_response(start_response, 400, 'Unknown product') email = params.get('email', '') signature = params.get('signature', '') if sign(config, email) != signature: return send_simple_response( start_response, 403, 'Invalid signature in verification request.', ) with open(filename, 'ab', 0) as file: fcntl.lockf(file, fcntl.LOCK_EX) try: print >>file, email finally: fcntl.lockf(file, fcntl.LOCK_UN) location = config.get('submit_email', 'successful_verification_redirect_location') location = location.format(lang=quote(params.get('lang') or 'en', '')) start_response('303 See Other', [('Location', location)]) return []
def send_installation_link(environ, start_response, data): email = data.get('email', '').strip() try: email = encode_email_address(email) except ValueError: return send_simple_response(start_response, 400, 'Please enter a valid email address.') config = get_config() template_path = config.get('send_installation_link', 'email_template') sendMail(template_path, {'recipient': email}) return send_simple_response( start_response, 200, 'The app is on the way! ' 'Please check your email on your smartphone or tablet.')
def send_installation_link(environ, start_response, data): email = data.get("email", "").strip() try: email = encode_email_address(email) except ValueError: return send_simple_response(start_response, 400, "Please enter a valid email address.") config = get_config() template_path = config.get("send_installation_link", "email_template") sendMail(template_path, {"recipient": email}) return send_simple_response( start_response, 200, "The app is on the way! " "Please check your email on your smartphone or tablet.")
def submit_email(environ, start_response, data): config = get_config() try: product = data['product'] template = config.get('submit_email', product + '_verification_email_template') except (KeyError, ConfigParser.NoOptionError): return send_simple_response(start_response, 400, 'Unknown product') email = data.get('email', '').strip() try: email = encode_email_address(email) except ValueError: return send_simple_response( start_response, 400, 'Please enter a valid email address.', ) params = [('email', email), ('signature', sign(config, email)), ('product', product)] lang = data.get('lang') if lang: params.append(('lang', lang)) sendMail( template, { 'recipient': email, 'verification_url': '%s?%s' % ( urljoin(wsgiref.util.application_uri(environ), VERIFICATION_PATH), urlencode(params), ), }, ) return send_simple_response( start_response, 200, 'A confirmation email has been sent. Please check ' 'your email and click the confirmation link.', )
def send_installation_link(environ, start_response, data): email = data.get('email', '').strip() try: email = encode_email_address(email) except ValueError: return send_simple_response( start_response, 400, 'Please enter a valid email address.', ) config = get_config() template_path = config.get('send_installation_link', 'email_template') sendMail(template_path, {'recipient': email}) return send_simple_response( start_response, 200, 'The app is on the way! ' 'Please check your email on your smartphone or tablet.', )