Skip to content

V16 RC: getOpenApiConfiguration().token does not work#19217

Merged
leekelleher merged 3 commits intorelease/16.0from
v16/bugfix/get-latest-token-private-member
May 6, 2025
Merged

V16 RC: getOpenApiConfiguration().token does not work#19217
leekelleher merged 3 commits intorelease/16.0from
v16/bugfix/get-latest-token-private-member

Conversation

@iOvergaard
Copy link
Contributor

Description

One line accidentally got changed compared to V15, so getting the latest token through the helpful "openApiConfiguration" object was no longer possible.

This pull request reverts the line to V15, where the token is proxied through the AuthContext, so we don't accidentally call a private member of AuthFlow.

Additionally, I have updated the umbraco-extension template to reflect that all contexts are now potentially undefined, because they can be revoked.

This fixes #19207

How to test

Go to a random element like the umbraco-news-dashboard.element.ts and test that you can get the token through the two officially supported methods:

	override firstUpdated() {
		this.consumeContext(UMB_AUTH_CONTEXT, async (auth) => {
			console.log('token 1', await auth?.getLatestToken());
			console.log('token 2', await auth?.getOpenApiConfiguration().token());
		});
	}

You should see token 1 and token 2 logged to the console.

Copilot AI review requested due to automatic review settings May 2, 2025 06:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reverts a change in how the token is accessed from the OpenAPI configuration to proxy the token through the AuthContext as in V15, and updates context types to handle potentially undefined values.

  • Reverts the direct token property access to using a function call in auth.context.ts.
  • Updates optional chaining and type annotations in entrypoint.ts and dashboard.element.ts to account for revoked contexts.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
templates/UmbracoExtension/Client/src/entrypoints/entrypoint.ts Reverts token access to use optional chaining and ensures safer config extraction.
templates/UmbracoExtension/Client/src/dashboards/dashboard.element.ts Updates state properties to reflect optional contexts and removes duplicate notification context declaration.
src/Umbraco.Web.UI.Client/src/packages/core/auth/auth.context.ts Wraps the getLatestToken call in a function to avoid direct access to a private member.

Copy link
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out, all good! 🚀

@leekelleher leekelleher merged commit 95bfee7 into release/16.0 May 6, 2025
23 checks passed
@leekelleher leekelleher deleted the v16/bugfix/get-latest-token-private-member branch May 6, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants