diff --git a/src/components/dashboard/users/UserPasswordForm.tsx b/src/components/dashboard/users/UserPasswordForm.tsx index f8eda44958..e8adb8ee16 100644 --- a/src/components/dashboard/users/UserPasswordForm.tsx +++ b/src/components/dashboard/users/UserPasswordForm.tsx @@ -7,6 +7,7 @@ import loading from '../../loading/loading'; import toast from '../../toast/toast'; import ButtonElement from '../../../elements/ButtonElement'; import InputElement from '../../../elements/InputElement'; +import { UserDto } from '@jellyfin/sdk/lib/generated-client'; type IProps = { userId: string | null; @@ -14,6 +15,7 @@ type IProps = { const UserPasswordForm: FunctionComponent = ({ userId }: IProps) => { const element = useRef(null); + let user: UserDto const loadUser = useCallback(async () => { const page = element.current; @@ -28,7 +30,7 @@ const UserPasswordForm: FunctionComponent = ({ userId }: IProps) => { return; } - const user = await window.ApiClient.getUser(userId); + user = await window.ApiClient.getUser(userId); const loggedInUser = await Dashboard.getCurrentUser(); if (!user.Policy || !user.Configuration) { @@ -76,6 +78,8 @@ const UserPasswordForm: FunctionComponent = ({ userId }: IProps) => { const onSubmit = (e: Event) => { if ((page.querySelector('#txtNewPassword') as HTMLInputElement).value != (page.querySelector('#txtNewPasswordConfirm') as HTMLInputElement).value) { toast(globalize.translate('PasswordMatchError')); + } else if((page.querySelector('#txtNewPassword') as HTMLInputElement).value == '' && user.Policy?.IsAdministrator) { + toast(globalize.translate('PasswordMissingSaveError')); } else { loading.show(); savePassword(); diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 12023468eb..218b388292 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1246,6 +1246,7 @@ "PasswordResetComplete": "The password has been reset.", "PasswordResetConfirmation": "Are you sure you wish to reset the password?", "PasswordResetProviderHelp": "Pick a password reset provider to be used when this user requests a password reset.", + "PasswordMissingSaveError": "New password cannot be empty.", "PasswordSaved": "Password saved.", "PathNotFound": "The path could not be found. Please ensure the path is valid and try again.", "Penciller": "Penciler",