def login(): if request.method == "GET": return render_template("login.html") else: username = request.form["username"].encode("ascii", "ignore") password = request.form["password"].encode("ascii", "ignore") if not auth.usedUsername(username): return 'Invalid username! <a href ="/login"> Please try again.</a>' elif auth.check(username, password): return 'Wrong password! <a href ="/login"> Please try again.</a>' session["username"] = username return redirect(url_for("home"))
def check_auth(request): auth_html = design.auth(url=url_for('method_auth')) try: user_id = request.cookies.get('ball_user_id') auth_token = request.cookies.get('ball_auth_token') except: return None, auth_html, False if not auth.check(user_id, auth_token): return None, auth_html, False # need to invalidate cache in action_access_* # if user_id in user_cache: # return user_cache[user_id] auth_html = design.auth_ok(user=str(user_id)) user_ok = user_id in config.allowed_users if not user_ok: db = DB() user_ok = db.volunteer_get(user_id) db.close(commit=True) user_cache[user_id] = user_id, auth_html, user_ok return user_cache[user_id]
def before_request(): if request.path.startswith( '/secrets' ) and not request.path == '/secrets/login' and not auth.check(): return redirect("/")
def root(): if auth.check(request): return pyhp.file("web/start.pyhp",{"db":database,"auth":auth}) else: return pyhp.file("web/login.pyhp",{"db":database,"auth":auth})
def before_request(): non_authorized_pages = ['/', '/auth'] if request.path in non_authorized_pages or auth.check(): return return redirect("/")
def savantChannelChange(channel): if auth.check(request.data): savantInterface.changeChannelNumeric(channel) return 'Channel changed to ' + channel else: return 'Not Auth'
def savantItv1(): if auth.check(request.data): savantInterface.changeChannel('ITV1') return 'TV on Virgin and ITV1' else: return 'Not Auth'
def savantCCOn(): if auth.check(request.data): savantInterface.chromecastOn() return 'TV on Chromecast' else: return 'Not Auth'
def savantOff(): if auth.check(request.data): savantInterface.off() return 'TV in the Living Room is off' else: return 'Not Auth'
def test(): print 'Receiving ...' if auth.check(request.data): print 'Auth ok' return 'Test Run'