- re done login con uuid;
- re done reset password con uuid; - re done user management con uuid;
This commit is contained in:
@@ -3,6 +3,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { isEmpty } from 'ramda';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
// tools
|
||||
import AuthenticationService from '../../service/authentication-service';
|
||||
@@ -16,7 +17,10 @@ import LogoIcon from '../../icons/LogoIcon';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Messages } from 'primereact/messages';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ResetPassword = () => {
|
||||
const navigate = useNavigate();
|
||||
const token = useStore().main.token();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [resetPassToken, setResetPassToken] = useState('');
|
||||
@@ -30,14 +34,23 @@ const ResetPassword = () => {
|
||||
setValue
|
||||
} = useForm({ mode: 'onChange' });
|
||||
|
||||
const gotToLoginAdmin = () => {
|
||||
navigate('/loginadmin');
|
||||
}
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
errorMsgs.current.clear();
|
||||
setLoading(true);
|
||||
const request = {
|
||||
...formData
|
||||
...formData,
|
||||
hubUuid: APP_HUB_ID
|
||||
}
|
||||
|
||||
AuthenticationService.forgotPassword(request, getCallback, errCallback);
|
||||
if (request.token && !isEmpty(request.token)) {
|
||||
AuthenticationService.resetPassword(request, getCallback, errCallback);
|
||||
} else {
|
||||
AuthenticationService.forgotPassword(request, getCallback, errCallback);
|
||||
}
|
||||
};
|
||||
|
||||
const getCallback = (data) => {
|
||||
@@ -59,7 +72,7 @@ const ResetPassword = () => {
|
||||
errorMsgs.current.show([
|
||||
{
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: sprintf(__('%s', 'gepafin'), err),
|
||||
detail: sprintf(__('%s', 'gepafin'), err.message),
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
@@ -104,7 +117,7 @@ const ResetPassword = () => {
|
||||
? <input
|
||||
type="hidden"
|
||||
name="token"
|
||||
{...register('test', {
|
||||
{...register('token', {
|
||||
required: true
|
||||
})}
|
||||
/> : null}
|
||||
@@ -144,6 +157,10 @@ const ResetPassword = () => {
|
||||
<Button
|
||||
label={__('Invia', 'gepafin')}
|
||||
disabled={loading}/>
|
||||
|
||||
<Button
|
||||
label={__('Accedi', 'gepafin')}
|
||||
link onClick={gotToLoginAdmin}/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user