Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Show login instead of 404 on credit-card for anon
Browse files Browse the repository at this point in the history
I'd like to link directly to the /credit-card.html page when publicizing
that we're back w/ credit card acceptance, but I don't want folks who
are unauthenticated to get a gnarly 404. #58
  • Loading branch information
chadwhitacre committed Jun 21, 2012
1 parent 9820970 commit 828f8a5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
52 changes: 32 additions & 20 deletions www/credit-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,42 @@
from gittip import billing

# ========================================================================== ^L
if user.ANON:
raise Response(404)

stripe_customer_id = user.stripe_customer_id
if not stripe_customer_id:
status = "missing"
else:
working = not bool(user.last_bill_result)
status = "working" if working else "failing"

try:
customer = billing.Customer(stripe_customer_id)
except: # stripe is unavailable? could be a bad stripe_customer_id?
log(traceback.format_exc())
stripe_down = True
else:
assert stripe_customer_id == customer['id']
stripe_down = False

username = user.id

if not user.ANON:
stripe_customer_id = user.stripe_customer_id
if not stripe_customer_id:
status = "missing"
else:
working = not bool(user.last_bill_result)
status = "working" if working else "failing"

try:
customer = billing.Customer(stripe_customer_id)
except: # stripe is unavailable? could be a bad stripe_customer_id?
log(traceback.format_exc())
stripe_down = True
else:
assert stripe_customer_id == customer['id']
stripe_down = False

username = user.id
# ========================================================================== ^L
{% extends templates/base.html %}


{% block body %}
{% if user.ANON %}
<div id="their-voice">

<h2 class="first">Credit Card</h2>

<p>Sign in <a href="{{ github_oauth_url('/credit-card.html') }}">with
GitHub</a>, and then you&rsquo;ll be able to add or change your credit card.
Thanks! :-)</p>

</div>

{% else %}
<script>
$(document).ready(function()
{
Expand Down Expand Up @@ -163,3 +174,4 @@ <h2>Delete credit card.</h2>

</div>
{% end %}
{% end %}
5 changes: 4 additions & 1 deletion www/github/associate
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ log("Done with OAuth dance with Github for %s (%s)."

# Bind to a participant.
# ======================
# Redirect to the new participant, or to the one they came from.
# Redirect to the new participant, or to the one they came from, or wherever
# else they came from.

participant_id = github.upsert(user_info, claim=True)
user = User.from_id(participant_id)
then = qs.get('then')
if then is not None:
if then.startswith('/'):
request.redirect(then)
participant_id = 'github/' + then
request.redirect('/%s/' % participant_id)

Expand Down

0 comments on commit 828f8a5

Please sign in to comment.