Compare commits

...

2 Commits

Author SHA1 Message Date
2ac9f28e5c Bump version: 1.4.10 → 1.4.11
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 3m42s
2025-08-10 10:23:40 +01:00
75cbcacf18 cache and multiple account fix 2025-08-10 10:22:53 +01:00
5 changed files with 40 additions and 14 deletions

View File

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

View File

@ -1 +1 @@
1.4.10
1.4.11

13
app.py
View File

@ -252,7 +252,9 @@ def add_account() -> Union[Response, str]:
if add_user_account(
base_url, session["auth_credentials"], username, password, stream
):
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
# Clear cache for user accounts route
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()
@ -267,11 +269,12 @@ def add_account() -> Union[Response, str]:
@app.route("/accounts/delete", methods=["POST"])
def delete_account() -> Response:
"""Handles deleting a user account."""
stream = request.form.get("stream")
username = request.form.get("username")
account_id = request.form.get("id")
base_url = app.config["BACKEND_URL"]
delete_user_account(base_url, session["auth_credentials"], stream, username)
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
delete_user_account(base_url, session["auth_credentials"], account_id)
# Clear cache for user accounts route
cache_key = f"view/{session['username']}/accounts"
cache.delete(cache_key)
return redirect(url_for("user_accounts"))
@app.route("/validateAccount", methods=["POST"])

View File

@ -58,9 +58,9 @@ def get_user_accounts(base_url: str, auth: str) -> List[Dict[str, Any]]:
return accounts
def delete_user_account(base_url: str, auth: str, stream: str, username: str) -> bool:
"""Deletes a user account via the API."""
payload = {"stream": stream, "user": username}
def delete_user_account(base_url: str, auth: str, account_id: str) -> bool:
"""Deletes a user account via the API using its ID."""
payload = {"id": account_id}
response = _make_api_request(
"POST", base_url, auth, "deleteAccount", payload=payload
)

View File

@ -53,8 +53,7 @@
<span class="button-text">Validate</span>
</button>
<form action="/accounts/delete" method="POST" style="display:inline;">
<input type="hidden" name="stream" value="{{ account.stream }}">
<input type="hidden" name="username" value="{{ account.username }}">
<input type="hidden" name="id" value="{{ account.id }}">
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this account?');">
Delete
</button>
@ -124,14 +123,38 @@
success: function(response) {
spinner.hide();
buttonText.show();
if (response.message === 'Account is valid and updated') {
if (response.message === 'Account is expired') {
button.prop('disabled', false);
button.removeClass('btn-info').addClass('btn-warning');
buttonText.text('Expired');
setTimeout(function() {
button.removeClass('btn-warning').addClass('btn-info');
buttonText.text('Validate');
}, 3000);
} else if (response.message === 'Account is valid and updated') {
button.prop('disabled', false);
button.removeClass('btn-info').addClass('btn-success');
buttonText.text('Valid & Updated');
// Display what was updated in a tooltip
if (response.updates && response.updates.length > 0) {
var updateDetails = response.updates.join('\n');
button.attr('title', updateDetails);
button.tooltip({
placement: 'bottom',
trigger: 'hover'
});
// Also show an alert with the updates
alert('Account updated:\n' + updateDetails);
}
setTimeout(function() {
button.removeClass('btn-success').addClass('btn-info');
buttonText.text('Validate');
}, 3000);
button.tooltip('dispose');
button.removeAttr('title');
}, 5000);
} else {
button.prop('disabled', false);
button.removeClass('btn-info').addClass('btn-success');