Compare commits
No commits in common. "2ac9f28e5c36890dae7d237b30d3034c01658ee6" and "8b9c100e871e291a9d81f4e1f75168392cbf84f4" have entirely different histories.
2ac9f28e5c
...
8b9c100e87
@ -1,5 +1,5 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "1.4.11"
|
current_version = "1.4.10"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
tag_name = "{new_version}"
|
tag_name = "{new_version}"
|
||||||
|
13
app.py
13
app.py
@ -252,9 +252,7 @@ def add_account() -> Union[Response, str]:
|
|||||||
if add_user_account(
|
if add_user_account(
|
||||||
base_url, session["auth_credentials"], username, password, stream
|
base_url, session["auth_credentials"], username, password, stream
|
||||||
):
|
):
|
||||||
# Clear cache for user accounts route
|
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
|
||||||
cache_key = f"view/{session['username']}/accounts"
|
|
||||||
cache.delete(cache_key)
|
|
||||||
# Run the NPM config update in a background thread
|
# Run the NPM config update in a background thread
|
||||||
thread = threading.Thread(target=_update_npm_config_in_background)
|
thread = threading.Thread(target=_update_npm_config_in_background)
|
||||||
thread.start()
|
thread.start()
|
||||||
@ -269,12 +267,11 @@ def add_account() -> Union[Response, str]:
|
|||||||
@app.route("/accounts/delete", methods=["POST"])
|
@app.route("/accounts/delete", methods=["POST"])
|
||||||
def delete_account() -> Response:
|
def delete_account() -> Response:
|
||||||
"""Handles deleting a user account."""
|
"""Handles deleting a user account."""
|
||||||
account_id = request.form.get("id")
|
stream = request.form.get("stream")
|
||||||
|
username = request.form.get("username")
|
||||||
base_url = app.config["BACKEND_URL"]
|
base_url = app.config["BACKEND_URL"]
|
||||||
delete_user_account(base_url, session["auth_credentials"], account_id)
|
delete_user_account(base_url, session["auth_credentials"], stream, username)
|
||||||
# Clear cache for user accounts route
|
cache.delete_memoized(user_accounts, key_prefix=make_cache_key)
|
||||||
cache_key = f"view/{session['username']}/accounts"
|
|
||||||
cache.delete(cache_key)
|
|
||||||
return redirect(url_for("user_accounts"))
|
return redirect(url_for("user_accounts"))
|
||||||
|
|
||||||
@app.route("/validateAccount", methods=["POST"])
|
@app.route("/validateAccount", methods=["POST"])
|
||||||
|
@ -58,9 +58,9 @@ def get_user_accounts(base_url: str, auth: str) -> List[Dict[str, Any]]:
|
|||||||
return accounts
|
return accounts
|
||||||
|
|
||||||
|
|
||||||
def delete_user_account(base_url: str, auth: str, account_id: str) -> bool:
|
def delete_user_account(base_url: str, auth: str, stream: str, username: str) -> bool:
|
||||||
"""Deletes a user account via the API using its ID."""
|
"""Deletes a user account via the API."""
|
||||||
payload = {"id": account_id}
|
payload = {"stream": stream, "user": username}
|
||||||
response = _make_api_request(
|
response = _make_api_request(
|
||||||
"POST", base_url, auth, "deleteAccount", payload=payload
|
"POST", base_url, auth, "deleteAccount", payload=payload
|
||||||
)
|
)
|
||||||
|
@ -53,7 +53,8 @@
|
|||||||
<span class="button-text">Validate</span>
|
<span class="button-text">Validate</span>
|
||||||
</button>
|
</button>
|
||||||
<form action="/accounts/delete" method="POST" style="display:inline;">
|
<form action="/accounts/delete" method="POST" style="display:inline;">
|
||||||
<input type="hidden" name="id" value="{{ account.id }}">
|
<input type="hidden" name="stream" value="{{ account.stream }}">
|
||||||
|
<input type="hidden" name="username" value="{{ account.username }}">
|
||||||
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this account?');">
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this account?');">
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
@ -123,38 +124,14 @@
|
|||||||
success: function(response) {
|
success: function(response) {
|
||||||
spinner.hide();
|
spinner.hide();
|
||||||
buttonText.show();
|
buttonText.show();
|
||||||
if (response.message === 'Account is expired') {
|
if (response.message === 'Account is valid and updated') {
|
||||||
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.prop('disabled', false);
|
||||||
button.removeClass('btn-info').addClass('btn-success');
|
button.removeClass('btn-info').addClass('btn-success');
|
||||||
buttonText.text('Valid & Updated');
|
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() {
|
setTimeout(function() {
|
||||||
button.removeClass('btn-success').addClass('btn-info');
|
button.removeClass('btn-success').addClass('btn-info');
|
||||||
buttonText.text('Validate');
|
buttonText.text('Validate');
|
||||||
button.tooltip('dispose');
|
}, 3000);
|
||||||
button.removeAttr('title');
|
|
||||||
}, 5000);
|
|
||||||
} else {
|
} else {
|
||||||
button.prop('disabled', false);
|
button.prop('disabled', false);
|
||||||
button.removeClass('btn-info').addClass('btn-success');
|
button.removeClass('btn-info').addClass('btn-success');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user