mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-12 17:11:20 +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"])
|
||||
def callback():
|
||||
state = session.get('oauth2_state')
|
||||
if not state or request.values.get('error'):
|
||||
return redirect(url_for('user.logout'))
|
||||
if not state:
|
||||
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_token = discord.fetch_token(
|
||||
token_url,
|
||||
client_secret=config['client-secret'],
|
||||
authorization_response=request.url)
|
||||
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['unauthenticated'] = False
|
||||
session.permanent = True
|
||||
@ -628,4 +630,4 @@ def patreon_sync_post():
|
||||
@user.route("/patreon/thanks")
|
||||
@discord_users_only()
|
||||
def patreon_thanks():
|
||||
return render_template("patreon.html.j2", state="thanks")
|
||||
return render_template("patreon.html.j2", state="thanks")
|
||||
|
Loading…
Reference in New Issue
Block a user