mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 22:47:04 +01:00
Include more informed error during callback
This commit is contained in:
parent
a75f0a276b
commit
9de25eb0d3
@ -30,15 +30,17 @@ def login_authenticated():
|
|||||||
@user.route('/callback', methods=["GET"])
|
@user.route('/callback', methods=["GET"])
|
||||||
def callback():
|
def callback():
|
||||||
state = session.get('oauth2_state')
|
state = session.get('oauth2_state')
|
||||||
if not state or request.values.get('error'):
|
if not state:
|
||||||
return redirect(url_for('user.logout'))
|
return redirect(url_for('user.logout', error="state_error"))
|
||||||
|
if request.values.get('error'):
|
||||||
|
return redirect(url_for('user.logout', error="discord_error {}".format(request.values.get('error'))))
|
||||||
discord = make_authenticated_session(state=state)
|
discord = make_authenticated_session(state=state)
|
||||||
discord_token = discord.fetch_token(
|
discord_token = discord.fetch_token(
|
||||||
token_url,
|
token_url,
|
||||||
client_secret=config['client-secret'],
|
client_secret=config['client-secret'],
|
||||||
authorization_response=request.url)
|
authorization_response=request.url)
|
||||||
if not discord_token:
|
if not discord_token:
|
||||||
return redirect(url_for('user.logout'))
|
return redirect(url_for('user.logout', error="discord_user_token_fetch_error"))
|
||||||
session['user_keys'] = discord_token
|
session['user_keys'] = discord_token
|
||||||
session['unauthenticated'] = False
|
session['unauthenticated'] = False
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
|
Loading…
Reference in New Issue
Block a user