From e043795a040b8666a6ad253bb6cd37a5d647bbd5 Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 3 Mar 2020 17:53:09 +0100 Subject: Add support for unlocking with Touch ID (#423) * Enhance installation guide in README * Add TouchID unlock for Ferdi Lock * Remove commit 8861014 as it is not related to this feature This reverts commit 88610144b942739772286ec3073b328e829a8b39. * Rename TouchID to "Touch ID" * Improve Touch ID prompt text * Improve unlocking with Touch ID * Fix lint * Add separator after lock-related menu entry Co-authored-by: Amine --- src/lib/Menu.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/lib/Menu.js') diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 6d5eb0095..957621f94 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js @@ -10,8 +10,9 @@ import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; import { workspaceActions } from '../features/workspaces/actions'; import { workspaceStore } from '../features/workspaces/index'; - -const { app, Menu, dialog } = remote; +const { + app, Menu, dialog, systemPreferences, +} = remote; const menuItems = defineMessages({ edit: { @@ -166,6 +167,14 @@ const menuItems = defineMessages({ id: 'menu.help.debugInfoCopiedBody', defaultMessage: '!!!Your Debug Information has been copied to your clipboard.', }, + touchId: { + id: 'locked.touchId', + defaultMessage: '!!!Unlock with Touch ID', + }, + touchIdPrompt: { + id: 'locked.touchIdPrompt', + defaultMessage: '!!!unlock via Touch ID', + }, tos: { id: 'menu.help.tos', defaultMessage: '!!!Terms of Service', @@ -833,6 +842,27 @@ export default class FranzMenu { if (todosStore.isFeatureEnabled) { tpl[5].submenu = this.todosMenu(); } + } else { + const touchIdEnabled = this.stores.settings.app.useTouchIdToUnlock && systemPreferences.canPromptTouchID(); + + tpl[0].submenu.unshift({ + label: intl.formatMessage(menuItems.touchId), + accelerator: 'CmdOrCtrl+Shift+L', + visible: touchIdEnabled, + click() { + systemPreferences.promptTouchID(intl.formatMessage(menuItems.touchIdPrompt)).then(() => { + actions.settings.update({ + type: 'app', + data: { + locked: false, + }, + }); + }); + }, + }, { + type: 'separator', + visible: touchIdEnabled + }); } tpl.unshift({ -- cgit v1.2.3-70-g09d2