diff --git a/src/data/auth.ts b/src/data/auth.ts index 95389e6fd9..29095dcf13 100644 --- a/src/data/auth.ts +++ b/src/data/auth.ts @@ -1,5 +1,6 @@ import { HaFormSchema } from "../components/ha-form/types"; import { HomeAssistant } from "../types"; +import { RefreshTokenType } from "./refresh_token"; export interface AuthUrlSearchParams { client_id?: string; @@ -137,7 +138,13 @@ export const adminChangePassword = ( password, }); -export const deleteAllRefreshTokens = (hass: HomeAssistant) => +export const deleteAllRefreshTokens = ( + hass: HomeAssistant, + token_type?: RefreshTokenType, + delete_current_token?: boolean +) => hass.callWS({ type: "auth/delete_all_refresh_tokens", + token_type, + delete_current_token, }); diff --git a/src/data/refresh_token.ts b/src/data/refresh_token.ts index bc2752bdf0..e5cbfef53b 100644 --- a/src/data/refresh_token.ts +++ b/src/data/refresh_token.ts @@ -4,6 +4,8 @@ declare global { } } +export type RefreshTokenType = "normal" | "long_lived_access_token"; + export interface RefreshToken { client_icon?: string; client_id: string; @@ -13,5 +15,5 @@ export interface RefreshToken { is_current: boolean; last_used_at?: string; last_used_ip?: string; - type: "normal" | "long_lived_access_token"; + type: RefreshTokenType; } diff --git a/src/panels/profile/ha-refresh-tokens-card.ts b/src/panels/profile/ha-refresh-tokens-card.ts index 6217936dcb..b6c340209d 100644 --- a/src/panels/profile/ha-refresh-tokens-card.ts +++ b/src/panels/profile/ha-refresh-tokens-card.ts @@ -9,6 +9,7 @@ import "../../components/ha-card"; import "../../components/ha-settings-row"; import "../../components/ha-icon-button"; import { RefreshToken } from "../../data/refresh_token"; +import { deleteAllRefreshTokens } from "../../data/auth"; import { showAlertDialog, showConfirmationDialog, @@ -108,6 +109,13 @@ class HaRefreshTokens extends LitElement { ) : ""} +