From 1d4eae5d0073cdda5f379011e6e76ffe25f155a5 Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Thu, 1 Jul 2021 16:44:10 -0300 Subject: [PATCH] fix: set minimum passcode length --- .../javascripts/directives/views/accountMenu.ts | 14 ++++++++++++-- app/assets/javascripts/strings.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/directives/views/accountMenu.ts b/app/assets/javascripts/directives/views/accountMenu.ts index cf6851e4ff6..cd4ae89840f 100644 --- a/app/assets/javascripts/directives/views/accountMenu.ts +++ b/app/assets/javascripts/directives/views/accountMenu.ts @@ -18,6 +18,7 @@ import { STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL, STRING_UNSUPPORTED_BACKUP_FILE_VERSION, StringUtils, + Strings, } from '@/strings'; import { PasswordWizardType } from '@/types'; import { @@ -509,8 +510,17 @@ class AccountMenuCtrl extends PureViewCtrl { } async submitPasscodeForm() { - const passcode = this.getState().formData.passcode!; - if (passcode !== this.getState().formData.confirmPasscode!) { + const passcode = this.getState().formData.passcode; + + if (!passcode || passcode.length === 0) { + await alertDialog({ + text: Strings.enterPasscode, + }); + this.passcodeInput[0].focus(); + return; + } + + if (passcode !== this.getState().formData.confirmPasscode) { await alertDialog({ text: STRING_NON_MATCHING_PASSCODES, }); diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index 1c112f341e7..217fb366d42 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -113,6 +113,7 @@ export const Strings = { openAccountMenu: 'Open Account Menu', trashNotesTitle: 'Move to Trash', trashNotesText: 'Are you sure you want to move these notes to the trash?', + enterPasscode: 'Please enter a passcode.', }; export const StringUtils = {