handle errors w/ twitter when logging in
This commit is contained in:
parent
1039da665b
commit
8a8d2cb0d3
|
@ -36,17 +36,22 @@ def index():
|
|||
settings_error = 'settings_error' in request.args
|
||||
)
|
||||
else:
|
||||
return render_template('index.html')
|
||||
return render_template('index.html',
|
||||
twitter_login_error = 'twitter_login_error' in request.args)
|
||||
|
||||
@app.route('/login/twitter')
|
||||
def twitter_login_step1():
|
||||
try:
|
||||
return redirect(lib.twitter.get_login_url(
|
||||
callback = url_for('twitter_login_step2', _external=True),
|
||||
**app.config.get_namespace("TWITTER_")
|
||||
))
|
||||
except (TwitterError, URLError):
|
||||
return redirect(url_for('index', twitter_login_error='', _anchor='log_in'))
|
||||
|
||||
@app.route('/login/twitter/callback')
|
||||
def twitter_login_step2():
|
||||
try:
|
||||
oauth_token = request.args['oauth_token']
|
||||
oauth_verifier = request.args['oauth_verifier']
|
||||
token = lib.twitter.receive_verifier(oauth_token, oauth_verifier, **app.config.get_namespace("TWITTER_"))
|
||||
|
@ -63,6 +68,8 @@ def twitter_login_step2():
|
|||
httponly=True,
|
||||
secure=app.config.get("HTTPS"))
|
||||
return resp
|
||||
except (TwitterError, URLError):
|
||||
return redirect(url_for('index', twitter_login_error='', _anchor='log_in'))
|
||||
|
||||
@app.route('/upload_tweet_archive', methods=('POST',))
|
||||
@require_auth
|
||||
|
|
|
@ -20,7 +20,13 @@
|
|||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Sign in</h2>
|
||||
<h2 id="sign_in">Sign in</h2>
|
||||
{% if twitter_login_error %}
|
||||
<div class="banner error">
|
||||
Sorry, something went wrong when communicating with Twitter. Give it another shot, maybe?
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p>Sound good to you? <a href="/login/twitter">Log in with Twitter</a></p>
|
||||
</section>
|
||||
<section class='policy'>
|
||||
|
|
Loading…
Reference in New Issue