added logging for unstable functions

This commit is contained in:
b3yond 2018-04-14 16:31:45 +02:00
parent d280130b29
commit 19cc64d00d

View file

@ -44,6 +44,7 @@ def register_post():
) )
return dict(info='Confirmation mail sent.') return dict(info='Confirmation mail sent.')
except Exception: except Exception:
logger.error("Could not send confirmation mail.", exc_info=True)
return dict(error='Could not send confirmation mail.') return dict(error='Could not send confirmation mail.')
@ -100,18 +101,21 @@ def login_twitter(user):
Starts the twitter OAuth authentication process. Starts the twitter OAuth authentication process.
:return: redirect to twitter. :return: redirect to twitter.
""" """
consumer_key = config["tapp"]["consumer_key"]
consumer_secret = config["tapp"]["consumer_secret"]
callback_url = request.get_header('host') + "/login/twitter/callback"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
try: try:
redirect_url = auth.get_authorization_url() consumer_key = config["tapp"]["consumer_key"]
except tweepy.TweepError: consumer_secret = config["tapp"]["consumer_secret"]
logger.error('Twitter OAuth Error: Failed to get request token.', callback_url = request.get_header('host') + "/login/twitter/callback"
exc_info=True) auth = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
return dict(error="Failed to get request token.") try:
user.save_request_token(auth.request_token) redirect_url = auth.get_authorization_url()
return bottle.redirect(redirect_url) except tweepy.TweepError:
logger.error('Twitter OAuth Error: Failed to get request token.',
exc_info=True)
return dict(error="Failed to get request token.")
user.save_request_token(auth.request_token)
return bottle.redirect(redirect_url)
except Exception:
logger.error("Error with Sign in with Twitter.", exc_info= True)
@get('/login/twitter/callback') @get('/login/twitter/callback')