Compare commits

...

3 Commits

Author SHA1 Message Date
473fecdcc7 Bump version: 1.4.13 → 1.4.14
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 2m6s
2025-08-18 14:44:44 +01:00
4deb681b99 fix(cache): clear additional caches in account-related routes
When updating, adding, or deleting accounts, multiple cache entries need to be invalidated to ensure data consistency. This includes clearing both memoized and regular cache entries for user accounts and the home page, which displays account statistics. The changes ensure that cached data is properly refreshed across all relevant views.
2025-08-18 14:17:24 +01:00
e2559fab30 fix(auth): add username validation and account check in login
Ensure case-sensitive username comparison and verify user has at least one account.
2025-08-18 14:03:46 +01:00
3 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "1.4.13"
current_version = "1.4.14"
commit = true
tag = true
tag_name = "{new_version}"

View File

@ -1 +1 @@
1.4.13
1.4.14

24
app.py
View File

@ -189,10 +189,21 @@ def login() -> Union[Response, str]:
response.raise_for_status()
response_data = response.json()
if response_data.get("auth") == "Success":
# Ensure case-sensitive username comparison
if response_data.get("username") != username:
return render_template("index.html", error="Invalid username or password. Please try again.")
session["logged_in"] = True
session["username"] = response_data.get("username", username)
session["user_id"] = response_data.get("user_id")
session["auth_credentials"] = encoded_credentials
# Check if the user has at least one account
base_url = app.config["BACKEND_URL"]
all_accounts = get_user_accounts(base_url, session["auth_credentials"])
if not all_accounts:
return render_template("index.html", error="No accounts associated with this user.")
next_url = request.args.get("next")
if next_url:
return redirect(next_url)
@ -255,6 +266,11 @@ def add_account() -> Union[Response, str]:
# Clear cache for user accounts route
cache_key = f"view/{session['username']}/accounts"
cache.delete(cache_key)
# Also clear memoized version for good measure
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
# Clear home page cache as well since it shows account stats
cache_key_home = f"view/{session['username']}/home"
cache.delete(cache_key_home)
# Run the NPM config update in a background thread
thread = threading.Thread(target=_update_npm_config_in_background)
thread.start()
@ -275,6 +291,11 @@ def delete_account() -> Response:
# Clear cache for user accounts route
cache_key = f"view/{session['username']}/accounts"
cache.delete(cache_key)
# Also clear memoized version for good measure
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
# Clear home page cache as well since it shows account stats
cache_key_home = f"view/{session['username']}/home"
cache.delete(cache_key_home)
return redirect(url_for("user_accounts"))
@app.route("/validateAccount", methods=["POST"])
@ -295,6 +316,9 @@ def validate_account() -> Tuple[Response, int]:
response_data = response.json()
if response_data.get("message") == "Account is valid and updated":
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
# Also clear regular cache for good measure
cache_key = f"view/{session['username']}/accounts"
cache.delete(cache_key)
# Run the NPM config update in a background thread
thread = threading.Thread(target=_update_npm_config_in_background)
thread.start()