Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Twitter login error handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jul 17, 2012
1 parent 86ab84e commit b2003df
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lastuserapp/views/oauthclient.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

from functools import wraps

from urllib import urlencode, quote
from urllib2 import urlopen, URLError
from urlparse import parse_qs
Expand Down Expand Up @@ -49,10 +51,22 @@ def login_twitter():
next=next_url))
except OAuthException, e:
flash("Twitter login failed: %s" % unicode(e), category="error")
return redirect(next_url)
return redirect(url_for('login'))


def twitter_exception_handler(f):
@wraps(f)
def decorated_function(*args, **kwargs):
try:
return f(*args, **kwargs)
except OAuthException, e:
flash("Twitter login failed: %s" % unicode(e), category="error")
return redirect(url_for('login'))
return decorated_function


@app.route('/login/twitter/callback')
@twitter_exception_handler
@twitter.authorized_handler
def login_twitter_authorized(resp):
next_url = get_next_url()
Expand Down

0 comments on commit b2003df

Please sign in to comment.