diff --git a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts index b70031f8d7..9e197cd717 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/auth/auth.interface.ts @@ -2,21 +2,31 @@ import type { UmbLoggedInUser } from './types.js'; import type { Observable } from '@umbraco-cms/backoffice/external/rxjs'; export interface IUmbAuth { + /** + * Initiates the login flow. + */ + login(): void; + /** * Initialise the auth flow. */ setInitialState(): Promise; /** - * Get the current user's access token. + * Gets the latest token from the Management API. + * If the token is expired, it will be refreshed. + * + * NB! The user may experience being redirected to the login screen if the token is expired. * * @example * ```js - * const token = await auth.getAccessToken(); + * const token = await authContext.getLatestToken(); * const result = await fetch('https://my-api.com', { headers: { Authorization: `Bearer ${token}` } }); * ``` + * + * @returns The latest token from the Management API */ - performWithFreshTokens(): Promise; + getLatestToken(): Promise; /** * Get the current user model of the current user. @@ -34,7 +44,7 @@ export interface IUmbAuth { fetchCurrentUser(): Promise; /** - * Sign out the current user. + * Signs the user out by removing any tokens from the browser. */ signOut(): Promise; }