mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix issues.
This commit is contained in:
@@ -7,10 +7,10 @@ export default function({ isAuthenticated =false, ...rest }) {
|
|||||||
const to = {pathname: '/dashboard/homepage'};
|
const to = {pathname: '/dashboard/homepage'};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BodyClassName className={'authentication'}>
|
<Route path="/auth">
|
||||||
<Route path="/auth">
|
{ (isAuthenticated) ?
|
||||||
{ (isAuthenticated) ?
|
(<Redirect to={to} />) : (
|
||||||
(<Redirect to={to} />) : (
|
<BodyClassName className={'authentication'}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<div class="authentication-page">
|
<div class="authentication-page">
|
||||||
<Link
|
<Link
|
||||||
@@ -30,9 +30,10 @@ export default function({ isAuthenticated =false, ...rest }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Switch>)
|
</Switch>
|
||||||
}
|
</BodyClassName>
|
||||||
</Route>
|
)
|
||||||
</BodyClassName>
|
}
|
||||||
|
</Route>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import BodyClassName from 'react-body-classname';
|
||||||
import { Route, Redirect } from 'react-router-dom';
|
import { Route, Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -13,19 +14,21 @@ function PrivateRoute({
|
|||||||
...rest
|
...rest
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Route
|
<BodyClassName className={''}>
|
||||||
{...rest}
|
<Route
|
||||||
path="/dashboard"
|
{...rest}
|
||||||
render={_props =>
|
path="/dashboard"
|
||||||
isAuthenticated ? (<Component {..._props} />) :
|
render={_props =>
|
||||||
(
|
isAuthenticated ? (<Component {..._props} />) :
|
||||||
<Redirect
|
(
|
||||||
to={{
|
<Redirect
|
||||||
pathname: '/auth/login',
|
to={{
|
||||||
}}
|
pathname: '/auth/login',
|
||||||
/>
|
}}
|
||||||
)}
|
/>
|
||||||
/>
|
)}
|
||||||
|
/>
|
||||||
|
</BodyClassName>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function Register({
|
|||||||
...initialValues,
|
...initialValues,
|
||||||
country: 'libya'
|
country: 'libya'
|
||||||
},
|
},
|
||||||
onSubmit: (values, { setSubmitting }) => {
|
onSubmit: (values, { setSubmitting, setErrors }) => {
|
||||||
requestRegister(values)
|
requestRegister(values)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
@@ -72,7 +72,17 @@ function Register({
|
|||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
history.push('/auth/login');
|
history.push('/auth/login');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((errors) => {
|
||||||
|
if (errors.some(e => e.type === 'PHONE_NUMBER_EXISTS')) {
|
||||||
|
setErrors({
|
||||||
|
phone_number: 'The phone number is already used in another account.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (errors.some(e => e.type === 'EMAIL_EXISTS')) {
|
||||||
|
setErrors({
|
||||||
|
email: 'The email is already used in another account.'
|
||||||
|
});
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -129,15 +129,16 @@ export default {
|
|||||||
.orWhere('phone_number', form.phone_number)
|
.orWhere('phone_number', form.phone_number)
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
|
const errorReasons = [];
|
||||||
|
|
||||||
if (user && user.phoneNumber === form.phone_number) {
|
if (user && user.phoneNumber === form.phone_number) {
|
||||||
return res.boom.badRequest(null, {
|
errorReasons.push({ type: 'PHONE_NUMBER_EXISTS', code: 100 });
|
||||||
errors: [{ type: 'PHONE_NUMBER_EXISTS', code: 100 }],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (user && user.email === form.email) {
|
if (user && user.email === form.email) {
|
||||||
return res.boom.badRequest(null, {
|
errorReasons.push({ type: 'EMAIL_EXISTS', code: 200 });
|
||||||
errors: [{ type: 'EMAIL_EXISTS', code: 200 }],
|
}
|
||||||
});
|
if (errorReasons.length > 0) {
|
||||||
|
return res.status(400).send({ errors: errorReasons });
|
||||||
}
|
}
|
||||||
const organizationId = uniqid();
|
const organizationId = uniqid();
|
||||||
const tenantOrganization = await Tenant.query().insert({
|
const tenantOrganization = await Tenant.query().insert({
|
||||||
|
|||||||
Reference in New Issue
Block a user