def twitter_auth(): oauth_verifier = request.args.get('oauth_verifier') # access_token cannot be used more than once access_token = get_access_token(session['request_token'], oauth_verifier) user = User.load_db_by_screen_name(access_token['screen_name']) if not user: user = User(access_token['screen_name'], access_token['oauth_token'], access_token['oauth_token_secret'], id=None) user.save_to_db() session['screen_name'] = user.screen_name return redirect(url_for('profile'))
def load_user(): if 'screen_name' in session: g.user = User.load_db_by_screen_name(session['screen_name'])