1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

improve state of mk

This commit is contained in:
Laurent Cozic 2022-04-13 12:13:03 +01:00
parent 20680f20a5
commit f12be8372c
4 changed files with 12 additions and 5 deletions

View File

@ -268,7 +268,7 @@ const EncryptionConfigScreen = (props: Props) => {
const buttonTitle = CommandService.instance().label('openMasterPasswordDialog');
const needPasswordMessage = !needMasterPassword ? null : (
<p className="needpassword">{_('Your master password is needed to decrypt some of your data.')}<br/>{_('Please click on "%s" to proceed', buttonTitle)}</p>
<p className="needpassword">{_('Your password is needed to decrypt some of your data.')}<br/>{_('Please click on "%s" to proceed, or set the passwords in the "%s" list below.', buttonTitle, _('Encryption keys'))}</p>
);
return (

View File

@ -5,6 +5,7 @@
.manage-password-section > .status {
display: flex;
flex-direction: row;
align-items: center;
}
.manage-password-section > .needpassword {

View File

@ -34,6 +34,12 @@ export default function(props: Props) {
const [updatingPassword, setUpdatingPassword] = useState(false);
const [mode, setMode] = useState<Mode>(Mode.Set);
const showCurrentPassword = useMemo(() => {
if ([MasterPasswordStatus.NotSet, MasterPasswordStatus.Invalid].includes(status)) return false;
if (mode === Mode.Reset) return false;
return true;
}, [status]);
const onClose = useCallback(() => {
props.dispatch({
type: 'DIALOG_CLOSE',
@ -63,7 +69,7 @@ export default function(props: Props) {
setUpdatingPassword(true);
try {
if (mode === Mode.Set) {
await updateMasterPassword(currentPassword, password1);
await updateMasterPassword(showCurrentPassword ? currentPassword : null, password1);
} else if (mode === Mode.Reset) {
await resetMasterPassword(EncryptionService.instance(), KvStore.instance(), ShareService.instance(), password1);
} else {
@ -115,7 +121,7 @@ export default function(props: Props) {
}, [password1, password2, updatingPassword, needToRepeatPassword]);
useEffect(() => {
setShowPasswordForm(status === MasterPasswordStatus.NotSet);
setShowPasswordForm([MasterPasswordStatus.NotSet, MasterPasswordStatus.Invalid].includes(status));
}, [status]);
useAsyncEffect(async (event: AsyncEffectEvent) => {
@ -131,8 +137,7 @@ export default function(props: Props) {
function renderPasswordForm() {
const renderCurrentPassword = () => {
if (status === MasterPasswordStatus.NotSet) return null;
if (mode === Mode.Reset) return null;
if (!showCurrentPassword) return null;
// If the master password is in the keychain we preload it into the
// field and allow displaying it. That way if the user has forgotten

View File

@ -275,4 +275,5 @@ Component-specific classes
.master-password-dialog .fa-times {
color: var(--joplin-color-error);
margin-left: 5px;
}