mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
Disconnect if bad websocket requests instead of flasks abort
This commit is contained in:
parent
9e53f16eb2
commit
a02b33a3cb
@ -74,6 +74,8 @@ class Gateway(Namespace):
|
|||||||
visitor_mode = data["visitor_mode"]
|
visitor_mode = data["visitor_mode"]
|
||||||
if not visitor_mode:
|
if not visitor_mode:
|
||||||
key = None
|
key = None
|
||||||
|
if "unauthenticated" not in session:
|
||||||
|
disconnect()
|
||||||
if session["unauthenticated"]:
|
if session["unauthenticated"]:
|
||||||
key = session["user_keys"][guild_id]
|
key = session["user_keys"][guild_id]
|
||||||
status = update_user_status(guild_id, session["username"], key)
|
status = update_user_status(guild_id, session["username"], key)
|
||||||
|
@ -3,6 +3,7 @@ import json
|
|||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
from flask import session, abort, url_for
|
from flask import session, abort, url_for
|
||||||
from titanembeds.utils import redis_store, make_user_cache_key
|
from titanembeds.utils import redis_store, make_user_cache_key
|
||||||
|
from flask_socketio import disconnect
|
||||||
|
|
||||||
authorize_url = "https://discordapp.com/api/oauth2/authorize"
|
authorize_url = "https://discordapp.com/api/oauth2/authorize"
|
||||||
token_url = "https://discordapp.com/api/oauth2/token"
|
token_url = "https://discordapp.com/api/oauth2/token"
|
||||||
@ -49,6 +50,9 @@ def get_user_guilds():
|
|||||||
return cache.decode("utf-8")
|
return cache.decode("utf-8")
|
||||||
req = discordrest_from_user("/users/@me/guilds")
|
req = discordrest_from_user("/users/@me/guilds")
|
||||||
if req.status_code != 200:
|
if req.status_code != 200:
|
||||||
|
if getattr(request, sid):
|
||||||
|
disconnect()
|
||||||
|
return
|
||||||
abort(req.status_code)
|
abort(req.status_code)
|
||||||
req = json.dumps(req.json())
|
req = json.dumps(req.json())
|
||||||
redis_store.set("OAUTH/USERGUILDS/"+str(make_user_cache_key()), req, 250)
|
redis_store.set("OAUTH/USERGUILDS/"+str(make_user_cache_key()), req, 250)
|
||||||
|
Loading…
Reference in New Issue
Block a user