From f2b2a1e3c3f4e3dbf3f46a272503a29ec243d3a6 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:10:49 -0300 Subject: [PATCH] Assert userName in socialProfile --- zwift_offline.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zwift_offline.py b/zwift_offline.py index fa3d3b52..5aa22aa8 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -901,7 +901,8 @@ def garmin(username): garth.login(request.form['username'], request.form['password']) garth.save('%s/%s/garth' % (STORAGE_DIR, current_user.player_id)) except Exception as exc: - flash(repr(exc)) + logger.warning('garth: %s' % repr(exc)) + flash("Invalid username or password.") return render_template("garmin.html", username=current_user.username) encrypt_credentials(file, (request.form['username'], request.form['password'])) return redirect(url_for('settings', username=current_user.username)) @@ -2269,7 +2270,7 @@ def garmin_upload(player_id, activity): tokens_dir = '%s/garth' % profile_dir try: garth.resume(tokens_dir) - requests.get('https://connectapi.garmin.com/userprofile-service/socialProfile', headers={'authorization': str(garth.client.oauth2_token)}).json() + assert 'userName' in requests.get('https://connectapi.garmin.com/userprofile-service/socialProfile', headers={'authorization': str(garth.client.oauth2_token)}).json() except: try: garth.login(username, password)