1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Remove easy password/pin configuration

This commit is contained in:
Bill Thornton 2023-07-13 10:29:47 -04:00
parent 0f37d59bb0
commit 4e7d89101e
2 changed files with 1 additions and 149 deletions

View file

@ -33,12 +33,9 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
LibraryMenu.setTitle(user.Name);
let showLocalAccessSection = false;
if (user.HasConfiguredPassword) {
(page.querySelector('#btnResetPassword') as HTMLDivElement).classList.remove('hide');
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.remove('hide');
showLocalAccessSection = true;
} else {
(page.querySelector('#btnResetPassword') as HTMLDivElement).classList.add('hide');
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.add('hide');
@ -46,23 +43,6 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
const canChangePassword = loggedInUser?.Policy?.IsAdministrator || user.Policy.EnableUserPreferenceAccess;
(page.querySelector('.passwordSection') as HTMLDivElement).classList.toggle('hide', !canChangePassword);
(page.querySelector('.localAccessSection') as HTMLDivElement).classList.toggle('hide', !(showLocalAccessSection && canChangePassword));
const txtEasyPassword = page.querySelector('#txtEasyPassword') as HTMLInputElement;
txtEasyPassword.value = '';
if (user.HasConfiguredEasyPassword) {
txtEasyPassword.placeholder = '******';
(page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.remove('hide');
} else {
txtEasyPassword.removeAttribute('placeholder');
txtEasyPassword.placeholder = '';
(page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.add('hide');
}
const chkEnableLocalEasyPassword = page.querySelector('.chkEnableLocalEasyPassword') as HTMLInputElement;
chkEnableLocalEasyPassword.checked = user.Configuration.EnableLocalPassword || false;
import('../../autoFocuser').then(({ default: autoFocuser }) => {
autoFocuser.autoFocus(page);
@ -125,75 +105,6 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
});
};
const onLocalAccessSubmit = (e: Event) => {
loading.show();
saveEasyPassword();
e.preventDefault();
return false;
};
const saveEasyPassword = () => {
const easyPassword = (page.querySelector('#txtEasyPassword') as HTMLInputElement).value;
if (easyPassword) {
window.ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
onEasyPasswordSaved();
}).catch(err => {
console.error('[UserPasswordForm] failed to update easy password', err);
});
} else {
onEasyPasswordSaved();
}
};
const onEasyPasswordSaved = () => {
window.ApiClient.getUser(userId).then(function (user) {
if (!user.Configuration) {
throw new Error('Unexpected null user.Configuration');
}
if (!user.Id) {
throw new Error('Unexpected null user.Id');
}
user.Configuration.EnableLocalPassword = (page.querySelector('.chkEnableLocalEasyPassword') as HTMLInputElement).checked;
window.ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () {
loading.hide();
toast(globalize.translate('SettingsSaved'));
loadUser().catch(err => {
console.error('[UserPasswordForm] failed to load user', err);
});
}).catch(err => {
console.error('[UserPasswordForm] failed to update user configuration', err);
});
}).catch(err => {
console.error('[UserPasswordForm] failed to fetch user', err);
});
};
const resetEasyPassword = () => {
const msg = globalize.translate('PinCodeResetConfirmation');
confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
loading.show();
window.ApiClient.resetEasyPassword(userId).then(function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('PinCodeResetComplete'),
title: globalize.translate('HeaderPinCodeReset')
});
loadUser().catch(err => {
console.error('[UserPasswordForm] failed to load user', err);
});
}).catch(err => {
console.error('[UserPasswordForm] failed to reset easy password', err);
});
}).catch(() => {
// confirm dialog was closed
});
};
const resetPassword = () => {
const msg = globalize.translate('PasswordResetConfirmation');
confirm(msg, globalize.translate('ResetPassword')).then(function () {
@ -216,9 +127,6 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
};
(page.querySelector('.updatePasswordForm') as HTMLFormElement).addEventListener('submit', onSubmit);
(page.querySelector('.localAccessForm') as HTMLFormElement).addEventListener('submit', onLocalAccessSubmit);
(page.querySelector('#btnResetEasyPassword') as HTMLButtonElement).addEventListener('click', resetEasyPassword);
(page.querySelector('#btnResetPassword') as HTMLButtonElement).addEventListener('click', resetPassword);
}, [loadUser, userId]);
@ -269,53 +177,6 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
</div>
</div>
</form>
<br />
<form
className='localAccessForm localAccessSection'
style={{ margin: '0 auto' }}
>
<div className='detailSection'>
<div className='detailSectionHeader'>
{globalize.translate('HeaderEasyPinCode')}
</div>
<br />
<div>
{globalize.translate('EasyPasswordHelp')}
</div>
<br />
<div className='inputContainer'>
<InputElement
type='number'
id='txtEasyPassword'
label='LabelEasyPinCode'
options={'autoComplete="off" pattern="[0-9]*" step="1" maxlength="5"'}
/>
</div>
<br />
<div className='checkboxContainer checkboxContainer-withDescription'>
<CheckBoxElement
className='chkEnableLocalEasyPassword'
title='LabelInNetworkSignInWithEasyPassword'
/>
<div className='fieldDescription checkboxFieldDescription'>
{globalize.translate('LabelInNetworkSignInWithEasyPasswordHelp')}
</div>
</div>
<div>
<ButtonElement
type='submit'
className='raised button-submit block'
title='Save'
/>
<ButtonElement
type='button'
id='btnResetEasyPassword'
className='raised button-cancel block hide'
title='ButtonResetEasyPassword'
/>
</div>
</div>
</form>
</div>
);
};