mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Add a button to delete all refresh tokens (#18680)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
5ebe1e0369
commit
6e66ba202f
@ -9,6 +9,7 @@ import "../../components/ha-card";
|
|||||||
import "../../components/ha-settings-row";
|
import "../../components/ha-settings-row";
|
||||||
import "../../components/ha-icon-button";
|
import "../../components/ha-icon-button";
|
||||||
import { RefreshToken } from "../../data/refresh_token";
|
import { RefreshToken } from "../../data/refresh_token";
|
||||||
|
import { deleteAllRefreshTokens } from "../../data/auth";
|
||||||
import {
|
import {
|
||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
@ -108,6 +109,13 @@ class HaRefreshTokens extends LitElement {
|
|||||||
)
|
)
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card-actions">
|
||||||
|
<mwc-button class="warning" @click=${this._deleteAllTokens}>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.profile.refresh_tokens.delete_all_tokens"
|
||||||
|
)}
|
||||||
|
</mwc-button>
|
||||||
|
</div>
|
||||||
</ha-card>`;
|
</ha-card>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +147,29 @@ class HaRefreshTokens extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _deleteAllTokens(): Promise<void> {
|
||||||
|
if (
|
||||||
|
!(await showConfirmationDialog(this, {
|
||||||
|
text: this.hass.localize(
|
||||||
|
"ui.panel.profile.refresh_tokens.confirm_delete_all"
|
||||||
|
),
|
||||||
|
destructive: true,
|
||||||
|
}))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await deleteAllRefreshTokens(this.hass);
|
||||||
|
} catch (err: any) {
|
||||||
|
await showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.profile.refresh_tokens.delete_failed"
|
||||||
|
),
|
||||||
|
text: err.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
|
@ -5537,6 +5537,8 @@
|
|||||||
"last_used": "Last used {date} from {location}",
|
"last_used": "Last used {date} from {location}",
|
||||||
"not_used": "Has never been used",
|
"not_used": "Has never been used",
|
||||||
"confirm_delete": "Are you sure you want to delete the refresh token for {name}?",
|
"confirm_delete": "Are you sure you want to delete the refresh token for {name}?",
|
||||||
|
"delete_all_tokens": "Delete all tokens",
|
||||||
|
"confirm_delete_all": "Are you sure you want to delete all refresh tokens? You will be logged out as part of this operation.",
|
||||||
"delete_failed": "Failed to delete the refresh token.",
|
"delete_failed": "Failed to delete the refresh token.",
|
||||||
"current_token_tooltip": "Unable to delete current refresh token"
|
"current_token_tooltip": "Unable to delete current refresh token"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user