mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-27 21:54:27 +01:00
(bug) for admins and managers, the current password is not requested before changing their own password
This commit is contained in:
parent
7c918ff497
commit
d05a6373be
@ -5,6 +5,7 @@
|
|||||||
- Improved calendars loading time
|
- Improved calendars loading time
|
||||||
- Refactored and documented the availability-slot-reservation data model
|
- Refactored and documented the availability-slot-reservation data model
|
||||||
- Display bookers names to connected users now apply to all resources
|
- Display bookers names to connected users now apply to all resources
|
||||||
|
- Fix a bug: for admins and managers, the current password is not requested before changing their own password
|
||||||
- Fix a bug: missing translation for avatar changing
|
- Fix a bug: missing translation for avatar changing
|
||||||
- Fix a bug: unable to book a space's slot with an existing reservation
|
- Fix a bug: unable to book a space's slot with an existing reservation
|
||||||
- Fix a bug: Unable to import accounts from SSO when the transformation modal was opened but leaved empty
|
- Fix a bug: Unable to import accounts from SSO when the transformation modal was opened but leaved empty
|
||||||
|
@ -9,19 +9,21 @@ import { FieldValues } from 'react-hook-form/dist/types/fields';
|
|||||||
import { PasswordInput } from './password-input';
|
import { PasswordInput } from './password-input';
|
||||||
import { FormState } from 'react-hook-form/dist/types/form';
|
import { FormState } from 'react-hook-form/dist/types/form';
|
||||||
import MemberAPI from '../../api/member';
|
import MemberAPI from '../../api/member';
|
||||||
|
import { User } from '../../models/user';
|
||||||
|
|
||||||
interface ChangePasswordProp<TFieldValues> {
|
interface ChangePasswordProp<TFieldValues> {
|
||||||
register: UseFormRegister<TFieldValues>,
|
register: UseFormRegister<TFieldValues>,
|
||||||
onError: (message: string) => void,
|
onError: (message: string) => void,
|
||||||
currentFormPassword: string,
|
currentFormPassword: string,
|
||||||
formState: FormState<TFieldValues>,
|
formState: FormState<TFieldValues>,
|
||||||
|
user: User,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component shows a button that trigger a modal dialog to verify the user's current password.
|
* This component shows a button that trigger a modal dialog to verify the user's current password.
|
||||||
* If the user's current password is correct, the modal dialog is closed and the button is replaced by a form to set the new password.
|
* If the user's current password is correct, the modal dialog is closed and the button is replaced by a form to set the new password.
|
||||||
*/
|
*/
|
||||||
export const ChangePassword = <TFieldValues extends FieldValues>({ register, onError, currentFormPassword, formState }: ChangePasswordProp<TFieldValues>) => {
|
export const ChangePassword = <TFieldValues extends FieldValues>({ register, onError, currentFormPassword, formState, user }: ChangePasswordProp<TFieldValues>) => {
|
||||||
const { t } = useTranslation('shared');
|
const { t } = useTranslation('shared');
|
||||||
|
|
||||||
const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false);
|
const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false);
|
||||||
@ -31,8 +33,8 @@ export const ChangePassword = <TFieldValues extends FieldValues>({ register, onE
|
|||||||
const { handleSubmit, register: passwordRegister } = useForm<{ password: string }>();
|
const { handleSubmit, register: passwordRegister } = useForm<{ password: string }>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
MemberAPI.current().then(user => {
|
MemberAPI.current().then(operator => {
|
||||||
setIsPrivileged(user.role === 'admin' || user.role === 'manager');
|
setIsPrivileged((operator.role === 'admin' || operator.role === 'manager') && user.id !== operator.id);
|
||||||
}).catch(error => onError(error));
|
}).catch(error => onError(error));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
|
|||||||
{ action === 'update' && <ChangePassword register={register}
|
{ action === 'update' && <ChangePassword register={register}
|
||||||
onError={onError}
|
onError={onError}
|
||||||
currentFormPassword={output.password}
|
currentFormPassword={output.password}
|
||||||
|
user={user}
|
||||||
formState={formState} />}
|
formState={formState} />}
|
||||||
{action === 'create' && <PasswordInput register={register}
|
{action === 'create' && <PasswordInput register={register}
|
||||||
currentFormPassword={output.password}
|
currentFormPassword={output.password}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user