All about user login
Not runnable at the moment
This commit is contained in:
parent
fbb8f5799e
commit
d79bbad575
49 changed files with 1554 additions and 686 deletions
|
|
@ -29,7 +29,7 @@ export default class CUD extends Component {
|
|||
|
||||
this.initForm({
|
||||
serverValidation: {
|
||||
url: '/users/rest/users-validate',
|
||||
url: '/rest/users-validate',
|
||||
changed: ['username', 'email'],
|
||||
extra: ['id']
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ export default class CUD extends Component {
|
|||
|
||||
@withAsyncErrorHandler
|
||||
async loadFormValues() {
|
||||
await this.getFormValuesFromURL(`/users/rest/users/${this.state.entityId}`, data => {
|
||||
await this.getFormValuesFromURL(`/rest/users/${this.state.entityId}`, data => {
|
||||
data.password = '';
|
||||
data.password2 = '';
|
||||
});
|
||||
|
|
@ -66,7 +66,6 @@ export default class CUD extends Component {
|
|||
const t = this.props.t;
|
||||
const edit = this.props.edit;
|
||||
|
||||
|
||||
const username = state.getIn(['username', 'value']);
|
||||
const usernameServerValidation = state.getIn(['username', 'serverValidation']);
|
||||
|
||||
|
|
@ -88,8 +87,6 @@ export default class CUD extends Component {
|
|||
state.setIn(['email', 'error'], t('Email must not be empty'));
|
||||
} else if (!emailServerValidation || emailServerValidation.invalid) {
|
||||
state.setIn(['email', 'error'], t('Invalid email address.'));
|
||||
} else if (!emailServerValidation || emailServerValidation.exists) {
|
||||
state.setIn(['email', 'error'], t('The email is already associated with another user in the system.'));
|
||||
} else {
|
||||
state.setIn(['email', 'error'], null);
|
||||
}
|
||||
|
|
@ -107,6 +104,8 @@ export default class CUD extends Component {
|
|||
const password = state.getIn(['password', 'value']) || '';
|
||||
const password2 = state.getIn(['password2', 'value']) || '';
|
||||
|
||||
const passwordResults = this.passwordValidator.test(password);
|
||||
|
||||
let passwordMsgs = [];
|
||||
|
||||
if (!edit && !password) {
|
||||
|
|
@ -114,7 +113,6 @@ export default class CUD extends Component {
|
|||
}
|
||||
|
||||
if (password) {
|
||||
const passwordResults = this.passwordValidator.test(password);
|
||||
passwordMsgs.push(...passwordResults.errors);
|
||||
}
|
||||
|
||||
|
|
@ -133,10 +131,10 @@ export default class CUD extends Component {
|
|||
let sendMethod, url;
|
||||
if (edit) {
|
||||
sendMethod = FormSendMethod.PUT;
|
||||
url = `/users/rest/users/${this.state.entityId}`
|
||||
url = `/rest/users/${this.state.entityId}`
|
||||
} else {
|
||||
sendMethod = FormSendMethod.POST;
|
||||
url = '/users/rest/users'
|
||||
url = '/rest/users'
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -194,7 +192,7 @@ export default class CUD extends Component {
|
|||
this.disableForm();
|
||||
this.setFormStatusMessage('info', t('Deleting user...'));
|
||||
|
||||
await axios.delete(`/users/rest/users/${this.state.entityId}`);
|
||||
await axios.delete(`/rest/users/${this.state.entityId}`);
|
||||
|
||||
this.navigateToWithFlashMessage('/users', 'success', t('User deleted'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import React, { Component } from 'react';
|
|||
import { translate } from 'react-i18next';
|
||||
import { Title, Toolbar, NavButton } from '../lib/page';
|
||||
import { Table } from '../lib/table';
|
||||
import mailtrainConfig from 'mailtrainConfig';
|
||||
|
||||
@translate()
|
||||
export default class List extends Component {
|
||||
|
|
@ -19,10 +20,13 @@ export default class List extends Component {
|
|||
|
||||
const columns = [
|
||||
{ data: 0, title: "#" },
|
||||
{ data: 1, title: "Username" },
|
||||
{ data: 2, title: "Full Name" }
|
||||
{ data: 1, title: "Username" }
|
||||
];
|
||||
|
||||
if (mailtrainConfig.isAuthMethodLocal) {
|
||||
columns.push({ data: 2, title: "Full Name" });
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Toolbar>
|
||||
|
|
@ -31,7 +35,7 @@ export default class List extends Component {
|
|||
|
||||
<Title>{t('Users')}</Title>
|
||||
|
||||
<Table withHeader dataUrl="/users/rest/users-table" columns={columns} actionLinks={actionLinks} />
|
||||
<Table withHeader dataUrl="/rest/users-table" columns={columns} actionLinks={actionLinks} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,31 +8,39 @@ import i18n from '../lib/i18n';
|
|||
import { Section } from '../lib/page'
|
||||
import CUD from './CUD'
|
||||
import List from './List'
|
||||
import mailtrainConfig from 'mailtrainConfig';
|
||||
|
||||
const getStructure = t => ({
|
||||
'': {
|
||||
title: t('Home'),
|
||||
externalLink: '/',
|
||||
children: {
|
||||
'users': {
|
||||
title: t('Users'),
|
||||
link: '/users',
|
||||
component: List,
|
||||
children: {
|
||||
'edit' : {
|
||||
title: t('Edit User'),
|
||||
params: [':id', ':action?'],
|
||||
render: props => (<CUD edit {...props} />)
|
||||
},
|
||||
'create' : {
|
||||
title: t('Create User'),
|
||||
render: props => (<CUD {...props} />)
|
||||
}
|
||||
const getStructure = t => {
|
||||
const subPaths = {};
|
||||
|
||||
if (mailtrainConfig.isAuthMethodLocal) {
|
||||
subPaths.edit = {
|
||||
title: t('Edit User'),
|
||||
params: [':id', ':action?'],
|
||||
render: props => (<CUD edit {...props} />)
|
||||
};
|
||||
|
||||
subPahts.create = {
|
||||
title: t('Create User'),
|
||||
render: props => (<CUD {...props} />)
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
'': {
|
||||
title: t('Home'),
|
||||
externalLink: '/',
|
||||
children: {
|
||||
users: {
|
||||
title: t('Users'),
|
||||
link: '/users',
|
||||
component: List,
|
||||
children: subPaths
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default function() {
|
||||
ReactDOM.render(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue