def test_black_list(self): self.assertEqual(blacklisted('andri000me_40', self.tbl), True) self.assertEqual(blacklisted('andri000me_12', self.tbl), True) self.assertEqual(blacklisted('magsberita', self.mbl), True) self.assertEqual(blacklisted('andriete', self.mbl), True) self.assertEqual(blacklisted('foozmeat', self.mbl), False)
def twitter_oauthorized(): try: resp = twitter_oauth.authorized_response() except OAuthException: resp = None if resp is None: flash( 'ERROR: You denied the request to sign in or have cookies disabled.' ) elif blacklisted(resp['screen_name'], app.config.get('TWITTER_BLACKLIST', [])): flash('ERROR: Access Denied.') send_blacklisted_email(app, resp['screen_name']) else: if 'bridge_id' in session: bridge = get_or_create_bridge(bridge_id=session['bridge_id']) if not bridge: pass # this should be an error else: bridge = get_or_create_bridge() bridge.twitter_oauth_token = resp['oauth_token'] bridge.twitter_oauth_secret = resp['oauth_token_secret'] bridge.twitter_handle = resp['screen_name'] db.session.commit() catch_up_twitter(bridge) email_bridge_details(app, bridge) return redirect(url_for('index'))
def twitter_oauthorized(): try: resp = twitter_oauth.authorized_response() except OAuthException: resp = None if resp is None: flash( 'ERROR: You denied the request to sign in or have cookies disabled.' ) elif blacklisted(resp['screen_name'], app.config.get('TWITTER_BLACKLIST', [])): flash('ERROR: Access Denied.') if app.config.get('MAIL_SERVER', None): body = render_template( 'access_denied.txt.j2', user=f"https://twitter.com/{resp['screen_name']}") msg = Message(subject="moa access denied", body=body, recipients=[app.config.get('MAIL_TO', None)]) try: mail.send(msg) except Exception as e: app.logger.error(e) else: session['twitter'] = resp return redirect(url_for('index'))