expect new end point for initial password
This commit is contained in:
@@ -2,8 +2,6 @@ export * from './change-password-modal.token.js';
|
||||
export * from './code-editor-modal.token.js';
|
||||
export * from './confirm-modal.token.js';
|
||||
export * from './create-dictionary-modal.token.js';
|
||||
export * from './create-user-modal.token.js';
|
||||
export * from './create-user-success-modal.token.js';
|
||||
export * from './current-user-modal.token.js';
|
||||
export * from './data-type-picker-flow-data-type-picker-modal.token.js';
|
||||
export * from './data-type-picker-flow-modal.token.js';
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { UMB_CREATE_USER_MODAL } from '../../modals/create/create-user-modal.token.js';
|
||||
import { UmbCollectionActionBase } from '@umbraco-cms/backoffice/collection';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type {
|
||||
UmbModalManagerContext} from '@umbraco-cms/backoffice/modal';
|
||||
import {
|
||||
UMB_CREATE_USER_MODAL,
|
||||
UMB_MODAL_MANAGER_CONTEXT
|
||||
} from '@umbraco-cms/backoffice/modal';
|
||||
import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal';
|
||||
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export class UmbCreateUserCollectionAction extends UmbCollectionActionBase {
|
||||
#modalManagerContext: UmbModalManagerContext | undefined;
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { UmbUserDetailRepository } from '../../repository/index.js';
|
||||
import { UMB_CREATE_USER_SUCCESS_MODAL } from './create-user-success-modal.token.js';
|
||||
import type { UmbUserGroupInputElement } from '@umbraco-cms/backoffice/user-group';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { css, html, customElement, query } from '@umbraco-cms/backoffice/external/lit';
|
||||
import type { UmbModalManagerContext } from '@umbraco-cms/backoffice/modal';
|
||||
import {
|
||||
UmbModalBaseElement,
|
||||
UMB_MODAL_MANAGER_CONTEXT,
|
||||
UMB_CREATE_USER_SUCCESS_MODAL,
|
||||
} from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalBaseElement, UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
@customElement('umb-user-create-modal')
|
||||
export class UmbUserCreateModalElement extends UmbModalBaseElement {
|
||||
@customElement('umb-create-user-modal')
|
||||
export class UmbCreateUserModalElement extends UmbModalBaseElement {
|
||||
#userDetailRepository = new UmbUserDetailRepository(this);
|
||||
#modalManagerContext?: UmbModalManagerContext;
|
||||
|
||||
@@ -53,16 +50,17 @@ export class UmbUserCreateModalElement extends UmbModalBaseElement {
|
||||
// TODO: figure out when to use email or username
|
||||
const { data } = await this.#userDetailRepository.create(userScaffold);
|
||||
|
||||
if (data && data.unique && data.initialPassword) {
|
||||
this.#openSuccessModal(data.unique, data.initialPassword);
|
||||
if (data) {
|
||||
this.#openSuccessModal(data.unique);
|
||||
}
|
||||
}
|
||||
|
||||
#openSuccessModal(userId: string, initialPassword: string) {
|
||||
#openSuccessModal(userUnique: string) {
|
||||
const modalContext = this.#modalManagerContext?.open(UMB_CREATE_USER_SUCCESS_MODAL, {
|
||||
data: {
|
||||
userId,
|
||||
initialPassword,
|
||||
user: {
|
||||
unique: userUnique,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -137,10 +135,10 @@ export class UmbUserCreateModalElement extends UmbModalBaseElement {
|
||||
];
|
||||
}
|
||||
|
||||
export default UmbUserCreateModalElement;
|
||||
export default UmbCreateUserModalElement;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-user-create-modal': UmbUserCreateModalElement;
|
||||
'umb-create-user-modal': UmbCreateUserModalElement;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,27 @@
|
||||
import { UmbUserItemRepository } from '../../repository/item/user-item.repository.js';
|
||||
import type { UmbUserItemModel } from '../../repository/item/types.js';
|
||||
import type {
|
||||
UmbCreateUserSuccessModalData,
|
||||
UmbCreateUserSuccessModalValue,
|
||||
} from './create-user-success-modal.token.js';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import type { UUIInputPasswordElement } from '@umbraco-cms/backoffice/external/uui';
|
||||
import type { UmbNotificationDefaultData, UmbNotificationContext } from '@umbraco-cms/backoffice/notification';
|
||||
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
|
||||
import type { UmbCreateUserSuccessModalData, UmbCreateUserSuccessModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
@customElement('umb-user-create-success-modal')
|
||||
export class UmbUserCreateSuccessModalElement extends UmbModalBaseElement<
|
||||
@customElement('umb-create-user-success-modal')
|
||||
export class UmbCreateUserSuccessModalElement extends UmbModalBaseElement<
|
||||
UmbCreateUserSuccessModalData,
|
||||
UmbCreateUserSuccessModalValue
|
||||
> {
|
||||
@state()
|
||||
_userItem?: UmbUserItemModel;
|
||||
|
||||
@state()
|
||||
_initialPassword: string = 'INITIAL PASSWORD GOES HERE';
|
||||
|
||||
#userItemRepository = new UmbUserItemRepository(this);
|
||||
#notificationContext?: UmbNotificationContext;
|
||||
|
||||
@@ -26,9 +32,10 @@ export class UmbUserCreateSuccessModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
|
||||
protected async firstUpdated(): Promise<void> {
|
||||
if (!this.data?.userId) throw new Error('No userId provided');
|
||||
if (!this.data?.user.unique) throw new Error('No user unique is provided');
|
||||
|
||||
const { data } = await this.#userItemRepository.requestItems([this.data?.userId]);
|
||||
// TODO: generate a new random password for the user, when the end point is ready
|
||||
const { data } = await this.#userItemRepository.requestItems([this.data?.user.unique]);
|
||||
if (data) {
|
||||
this._userItem = data[0];
|
||||
}
|
||||
@@ -55,8 +62,8 @@ export class UmbUserCreateSuccessModalElement extends UmbModalBaseElement<
|
||||
|
||||
#onGoToProfile(event: Event) {
|
||||
event.stopPropagation();
|
||||
history.pushState(null, '', 'section/user-management/view/users/user/' + this.id); //TODO: URL Should be dynamic
|
||||
this.modalContext?.submit();
|
||||
history.pushState(null, '', 'section/user-management/view/users/user/' + this.data?.user.unique); //TODO: URL Should be dynamic
|
||||
this._submitModal();
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -65,12 +72,7 @@ export class UmbUserCreateSuccessModalElement extends UmbModalBaseElement<
|
||||
<uui-form-layout-item>
|
||||
<uui-label slot="label" for="password">Password</uui-label>
|
||||
<div id="password-control">
|
||||
<uui-input-password
|
||||
id="password"
|
||||
label="password"
|
||||
name="password"
|
||||
value="${this.data?.initialPassword ?? ''}"
|
||||
readonly>
|
||||
<uui-input-password id="password" label="password" name="password" value="${this._initialPassword}" readonly>
|
||||
</uui-input-password>
|
||||
<uui-button compact label="Copy" @click=${this.#copyPassword} look="outline"></uui-button>
|
||||
</div>
|
||||
@@ -104,10 +106,10 @@ export class UmbUserCreateSuccessModalElement extends UmbModalBaseElement<
|
||||
];
|
||||
}
|
||||
|
||||
export default UmbUserCreateSuccessModalElement;
|
||||
export default UmbCreateUserSuccessModalElement;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-user-create-success-modal': UmbUserCreateSuccessModalElement;
|
||||
'umb-create-user-success-modal': UmbCreateUserSuccessModalElement;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
export interface UmbCreateUserSuccessModalData {
|
||||
userId: string;
|
||||
initialPassword: string;
|
||||
user: {
|
||||
unique: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type UmbCreateUserSuccessModalValue = undefined;
|
||||
@@ -5,13 +5,13 @@ const modals: Array<ManifestModal> = [
|
||||
type: 'modal',
|
||||
alias: 'Umb.Modal.User.Create',
|
||||
name: 'Create User Modal',
|
||||
js: () => import('./create/user-create-modal.element.js'),
|
||||
js: () => import('./create/create-user-modal.element.js'),
|
||||
},
|
||||
{
|
||||
type: 'modal',
|
||||
alias: 'Umb.Modal.User.CreateSuccess',
|
||||
name: 'Create Success User Modal',
|
||||
js: () => import('./create/user-create-success-modal.element.js'),
|
||||
js: () => import('./create/create-user-success-modal.element.js'),
|
||||
},
|
||||
{
|
||||
type: 'modal',
|
||||
|
||||
@@ -119,7 +119,7 @@ export class UmbUserServerDataSource implements UmbDetailDataSource<UmbUserDetai
|
||||
);
|
||||
|
||||
if (data) {
|
||||
// TODO: what do we do with the initial password?
|
||||
// TODO: get back to this when we get a location header
|
||||
return this.read(data.user.id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user