Example #1
0
File: app.py Project: olin/seamlist
	r = unsubscribe_user(session['email'], get_user_key(session['email']), request.form['listid'])
	return 'Unsubscribed. <p><a href="/">Go back?</a><h4>Contents:</h4><pre>' + r.text

@app.route("/subscribe", methods=['POST'])
def subscribe():
	r = subscribe_user(session['email'], get_user_key(session['email']), request.form['listid'])
	return 'Subscription request sent. Check your inbox! <p><a href="/">Go back?</a><h4>Contents:</h4><pre>' + r.text

# Fwol.in Authentication
# ----------------------

# First-time logged in action.
def logged_in(newlogin):
	# See if we have access to the user's passwords.
	if not session.get('seamlist-active', False):
		session['seamlist-active'] = session['email'] in get_seamlist_subscriptions()
	# Auto-reset passwords.
	if newlogin and session['seamlist-active']:
		print('Resetting all passwords for ' + session['email'])
		reset_all_user_passwords(session['email'], get_user_key(session['email']), get_user_key(session['email']), SEAMLIST_ID)

fwolin.enable_auth(app, logged_in)

# Launch
# ------

if __name__ == "__main__":
	port = int(os.environ.get("PORT", 5000))
	app.debug = True
	app.run(host='0.0.0.0', port=port)
Example #2
0
from flask import Flask, session, request, redirect, url_for, render_template
app = Flask(__name__, static_url_path='')
Flask.secret_key = os.environ.get('FLASK_SESSION_KEY', 'test-key-please-ignore')

# Routes
# ------

@app.route('/')
def index():
	return render_template('index.html', email=session['email'])

@app.route('/login/')
def login():
	return render_template('login.html')

# Fwol.in Authentication
# ----------------------

fwolin.enable_auth(app, None, ['/login/', '/login'])

# Launch
# ------

if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    app.debug = True
    if 'PORT' in os.environ:
    	app.config.update(SERVER_NAME='fwol.in')
    app.run(host='0.0.0.0', port=port)
Example #3
0
import os, random, string, requests, json, re, time, fwolin
from flask import Flask, session, request, redirect, url_for, render_template

# Initialize Flask application.
app = Flask(__name__, static_url_path='')

# Use fwol.in's unified authentication mechanism.
# This requires us to set an environment variable for this application
# to encrypt the user's session.
fwolin.enable_auth(app)
Flask.secret_key = os.environ.get('FLASK_SESSION_KEY', 'test-key-please-ignore')

# Routes
# ------

@app.route('/')
def index():
	return render_template('index.html', email=session['email'])

# Launch
# ------

if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    app.debug = True
    if 'PORT' in os.environ:
    	app.config.update(SERVER_NAME='fwol.in')
    app.run(host='0.0.0.0', port=port)