Skip to content

Commit

Permalink
Preparing for beta
Browse files Browse the repository at this point in the history
  • Loading branch information
mdirolf committed Oct 12, 2011
1 parent 211f5bb commit e2d4e4e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
5 changes: 4 additions & 1 deletion fiesta.py
Expand Up @@ -11,6 +11,9 @@
import settings


INDEX = "/top_secret"


@decorator.decorator
def authorize(view, *args, **kwargs):
if "f" not in flask.session or \
Expand All @@ -19,7 +22,7 @@ def authorize(view, *args, **kwargs):
if flask.request.method == "GET":
return flask.redirect(auth_url(flask.request.url))
elif flask.request.method == "POST":
referrer = flask.request.headers.get("REFERER", "/")
referrer = flask.request.headers.get("REFERER", INDEX)
return flask.redirect(auth_url(referrer))

return view(*args, **kwargs)
Expand Down
7 changes: 5 additions & 2 deletions github.py
Expand Up @@ -9,6 +9,9 @@
import settings


INDEX = "/top_secret"


class Reauthorize(Exception):
pass

Expand All @@ -19,7 +22,7 @@ def reauthorize(view, *args, **kwargs):
return view(*args, **kwargs)
except Reauthorize:
del flask.session["g"]
return flask.redirect("/")
return flask.redirect(INDEX)


@decorator.decorator
Expand Down Expand Up @@ -47,7 +50,7 @@ def token(code):

def finish_auth():
flask.session["g"] = token(flask.request.args["code"])
return flask.redirect("/")
return flask.redirect(INDEX)


def make_request(u, big=False):
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Expand Up @@ -22,7 +22,7 @@
{% block content %}{% endblock %}
<div id="f">
<hr>
This site is <a href="http://github.com/fiesta/gitlists">open source</a>. <a href="mailto:support@corp.fiesta.cc">Need a hand?</a><span id="copy">&copy; 2011 <a href="https://fiesta.cc">Fiesta</a></span>
{% block footer %}This site is <a href="http://github.com/fiesta/gitlists">open source</a>. <a href="mailto:support@corp.fiesta.cc">Need a hand?</a>{% endblock %}<span id="copy">&copy; 2011 <a href="https://fiesta.cc">Fiesta</a></span>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions templates/beta_index.html
@@ -0,0 +1,22 @@
{% extends "base.html" %}

{% block content %}
<h1>Gitlists</h1>

<p>We're in private beta right now.</p>

<p>Apologies for being coy.</p>

<p>Sign up below to get on the list, or just bug us <a href="http://twitter.com/gitlists">on twitter</a>.</p>

<form method="POST" action="/beta">
<label>
Your github username:
<input type="text" name="github">
</label>
<input type="submit" value="Party on">
</form>
{% endblock %}

{% block footer %}
{% endblock %}
16 changes: 14 additions & 2 deletions www.py
Expand Up @@ -12,6 +12,13 @@
import sign


# If you looked through the source to find this link, then you deserve
# access to the beta :).
#
# But, if you don't mind, keep it on the DL. It's top secret.
INDEX = "/top_secret"


app = flask.Flask(__name__)
app.secret_key = settings.session_key

Expand Down Expand Up @@ -54,13 +61,18 @@ def check_xsrf(view, *args, **kwargs):
return flask.abort(403, "Bad XSRF token.")
elif status == sign.TIMEOUT:
flask.flash("Your session timed out, please try again.")
redirect = flask.request.headers.get("REFERER", "/")
redirect = flask.request.headers.get("REFERER", INDEX)
return flask.redirect(redirect)
return view(*args, **kwargs)
return decorator.decorator(check_xsrf)


@app.route("/")
def beta_index():
return flask.render_template("beta_index.html")


@app.route(INDEX)
@github.reauthorize
def index():
if "g" in flask.session:
Expand Down Expand Up @@ -253,7 +265,7 @@ def create_post():
flask.flash("Please check your '%s' inbox to confirm your gitlist." % user["email"])
else:
flask.flash("You should receive a welcome message at '%s'." % user["email"])
return flask.redirect("/")
return flask.redirect(INDEX)


@app.route("/auth/github")
Expand Down

0 comments on commit e2d4e4e

Please sign in to comment.