Skip to content

Commit

Permalink
Assert userName in socialProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm committed Nov 28, 2024
1 parent da27d77 commit f2b2a1e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f2b2a1e

Please sign in to comment.