mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 10:01:21 +01:00
401 error when invalid grant error is raised
This commit is contained in:
parent
d51410d802
commit
c45c98dfb9
@ -5,6 +5,7 @@ from flask import session, abort, url_for, request
|
||||
from titanembeds.utils import redis_store, make_user_cache_key
|
||||
from flask_socketio import disconnect
|
||||
import time
|
||||
from oauthlib.oauth2.rfc6749.errors import InvalidGrantError
|
||||
|
||||
authorize_url = "https://discordapp.com/api/oauth2/authorize"
|
||||
token_url = "https://discordapp.com/api/oauth2/token"
|
||||
@ -32,7 +33,10 @@ def make_authenticated_session(token=None, state=None, scope=None):
|
||||
def discordrest_from_user(endpoint):
|
||||
token = session['user_keys']
|
||||
discord = make_authenticated_session(token=token)
|
||||
try:
|
||||
req = discord.get("https://discordapp.com/api/v6{}".format(endpoint))
|
||||
except InvalidGrantError as ex:
|
||||
abort(401)
|
||||
return req
|
||||
|
||||
def get_current_authenticated_user():
|
||||
|
@ -1845,10 +1845,10 @@
|
||||
});
|
||||
fet.fail(function(data) {
|
||||
if (data.status == 403) {
|
||||
$('#loginmodal').modal('open');
|
||||
setTimeout(function () {$('#loginmodal').modal('open');}, 2000);
|
||||
Materialize.toast('Authentication error! You have been disconnected by the server.', 10000);
|
||||
} else if (data.status == 401) {
|
||||
$('#loginmodal').modal('open');
|
||||
setTimeout(function () {$('#loginmodal').modal('open');}, 2000);
|
||||
Materialize.toast('Session expired! You have been logged out.', 10000);
|
||||
}
|
||||
setVisitorMode(true);
|
||||
|
Loading…
Reference in New Issue
Block a user