export types from the appauth module to fix tests

This commit is contained in:
Jacob Overgaard
2024-04-08 10:16:24 +02:00
parent 28b8729ccc
commit 1dba67ac43
2 changed files with 24 additions and 48 deletions

View File

@@ -5,14 +5,12 @@ export {
LocalStorageBackend,
RedirectRequestHandler,
RevokeTokenRequest,
} from '@openid/appauth';
export { AuthorizationRequest } from '@openid/appauth/built/authorization_request';
export { AuthorizationNotifier } from '@openid/appauth/built/authorization_request_handler';
export { AuthorizationServiceConfiguration } from '@openid/appauth/built/authorization_service_configuration';
export {
AuthorizationNotifier,
AuthorizationRequest,
AuthorizationServiceConfiguration,
GRANT_TYPE_AUTHORIZATION_CODE,
GRANT_TYPE_REFRESH_TOKEN,
TokenRequest,
} from '@openid/appauth/built/token_request';
export { TokenResponse } from '@openid/appauth/built/token_response';
export type { LocationLike, StringMap } from '@openid/appauth/built/types';
TokenResponse,
} from '@openid/appauth';
export type { LocationLike, StringMap } from '@openid/appauth';

View File

@@ -1,61 +1,39 @@
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UMB_AUTH_CONTEXT } from '../core/auth/auth.context.token.js';
import { tryExecuteAndNotify } from '../core/resources/tryExecuteAndNotify.function.js';
import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UserGroupResource, type UserGroupResponseModel } from '@umbraco-cms/backoffice/external/backend-api';
@customElement('umb-umbraco-news-dashboard')
export class UmbUmbracoNewsDashboardElement extends UmbLitElement {
#currentUserContext?: typeof UMB_CURRENT_USER_CONTEXT.TYPE;
@state()
private _name = '';
_groups: UserGroupResponseModel[] = [];
constructor() {
super();
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (instance) => {
this.#currentUserContext = instance;
this.#observeCurrentUser();
});
async clearToken() {
const authContext = await this.getContext(UMB_AUTH_CONTEXT);
authContext.clearTokenStorage();
}
#observeCurrentUser(): void {
if (!this.#currentUserContext) return;
this.observe(this.#currentUserContext.currentUser, (user) => {
this._name = user?.name ?? '';
});
async makeAuthorizedRequest() {
const { data } = await tryExecuteAndNotify(this, UserGroupResource.getUserGroup({ skip: 0, take: 10 }));
if (data) {
this._groups = data.items;
}
}
render() {
return html`
<uui-box class="uui-text">
<h1 class="uui-h2" style="margin-top: var(--uui-size-layout-1);">
<umb-localize key="dashboard_welcome">Welcome</umb-localize>, ${this._name}
</h1>
<p class="uui-lead">
This is the beta version of Umbraco 14, where you can have a first-hand look at the new Backoffice.
</p>
<p>
Please refer to the
<a target="_blank" href="https://docs.umbraco.com/umbraco-cms/v/14.latest-beta/">documentation</a> to learn
more about what is possible. Here you will find excellent tutorials, guides, and references to help you get
started extending the Backoffice.
<uui-button look="primary" @click=${this.clearToken}>Clear all tokens</uui-button>
<uui-button look="primary" @click=${this.makeAuthorizedRequest}>Make authorized request</uui-button>
${this._groups.map((group) => html` <p>${group.name}</p> `)}
</p>
</uui-box>
`;
}
static styles = [
UmbTextStyles,
css`
:host {
display: block;
padding: var(--uui-size-layout-1);
}
p {
position: relative;
}
`,
];
}
export default UmbUmbracoNewsDashboardElement;