From bd7a03aec21bdd7f7c4336f7b88905bfdc915549 Mon Sep 17 00:00:00 2001 From: zoffline Date: Fri, 31 Aug 2018 17:42:06 -0400 Subject: [PATCH] Use a redirect to launch instead of direct link (issue #6) I have no idea why OS X's WebView seems to care whether it gets the launch URL via a link or redirect, but apparently it does. Cleaner this way anyway. --- auth_server.py | 10 +++------- cdn/static/web/launcher/embed-noauto.html | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/auth_server.py b/auth_server.py index f7fff59..dca2223 100755 --- a/auth_server.py +++ b/auth_server.py @@ -26,25 +26,21 @@ def api_auth(): return 'OK(Java)' +@app.route('/launcher', methods=['GET']) @app.route('/auth/realms/zwift/protocol/openid-connect/auth', methods=['GET']) @app.route('/auth/realms/zwift/login-actions/request/login', methods=['GET', 'POST']) @app.route('/auth/realms/zwift/protocol/openid-connect/registrations', methods=['GET']) @app.route('/auth/realms/zwift/login-actions/startriding', methods=['GET']) # Unused as it's a direct redirect now from auth/login @app.route('/auth/realms/zwift/tokens/login', methods=['GET']) # Called by Mac, but not Windows -@app.route('/launcher', methods=['GET']) # Called by Mac, but not Windows @app.route('/auth/realms/zwift/tokens/registrations', methods=['GET']) # Called by Mac, but not Windows +@app.route('/ride', methods=['GET']) def launch_zwift(): - if not os.path.exists(AUTOLAUNCH_FILE): + if request.path != "/ride" and not os.path.exists(AUTOLAUNCH_FILE): return redirect(NOAUTO_EMBED, 302) else: return redirect("http://zwift/?code=zwift_refresh_token%s" % REFRESH_TOKEN, 302) -#@app.route('/auth/realms/zwift/protocol/openid-connect/logout', methods=['GET']) -#def auth_realms_zwift_protocol_openid_connect_logout(): -# return redirect("https://secure.zwift.com/auth/realms/zwift/protocol/openid-connect/auth?client_id=Game_Launcher&response_type=code&redirect_uri=http://zwift/", code=302) - - @app.route('/auth/realms/zwift/protocol/openid-connect/token', methods=['POST']) def auth_realms_zwift_protocol_openid_connect_token(): return FAKE_JWT, 200 diff --git a/cdn/static/web/launcher/embed-noauto.html b/cdn/static/web/launcher/embed-noauto.html index 10d9515..6377ebf 100644 --- a/cdn/static/web/launcher/embed-noauto.html +++ b/cdn/static/web/launcher/embed-noauto.html @@ -5,7 +5,7 @@

zoffline Launcher



-

Click here to start Zwift

+

Click here to start Zwift



To automatically launch Zwift and skip this step create a file called "auto_launch.txt" inside zoffline's storage directory.