From 74fb3b6ca5bad73578167e90f94b09054d3e103f Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Mon, 17 Dec 2018 18:08:54 -0600 Subject: [PATCH] Show privileges manager if protection not set up --- .../javascripts/app/controllers/editor.js | 7 +++++++ .../app/services/privilegesManager.js | 14 ++++++++----- .../privileges-management-modal.html.haml | 21 ++++++++++--------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index 9aa1c96ae..98620e836 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -415,6 +415,13 @@ angular.module('app') this.toggleProtectNote = function() { this.note.content.protected = !this.note.content.protected; this.changesMade({dontUpdateClientModified: true, dontUpdatePreviews: true}); + + // Show privilegesManager if Protection is not yet set up + privilegesManager.actionHasPrivilegesConfigured(PrivilegesManager.ActionViewProtectedNotes).then((configured) => { + if(!configured) { + privilegesManager.presentPrivilegesManagementModal(); + } + }) } this.toggleNotePreview = function() { diff --git a/app/assets/javascripts/app/services/privilegesManager.js b/app/assets/javascripts/app/services/privilegesManager.js index f79177784..a1c83f077 100644 --- a/app/assets/javascripts/app/services/privilegesManager.js +++ b/app/assets/javascripts/app/services/privilegesManager.js @@ -30,12 +30,12 @@ class PrivilegesManager { PrivilegesManager.SessionLengthOneWeek = 604800; this.availableActions = [ - PrivilegesManager.ActionManagePrivileges, - PrivilegesManager.ActionManageExtensions, - PrivilegesManager.ActionManageBackups, - PrivilegesManager.ActionManagePasscode, PrivilegesManager.ActionViewProtectedNotes, - PrivilegesManager.ActionDeleteNote + PrivilegesManager.ActionDeleteNote, + PrivilegesManager.ActionManagePasscode, + PrivilegesManager.ActionManageBackups, + PrivilegesManager.ActionManageExtensions, + PrivilegesManager.ActionManagePrivileges, ] this.availableCredentials = [ @@ -249,6 +249,10 @@ class PrivilegesManager { } } + async actionHasPrivilegesConfigured(action) { + return (await this.netCredentialsForAction(action)).length > 0; + } + async actionRequiresPrivilege(action) { let expiresAt = await this.getSessionExpirey(); if(expiresAt > new Date()) { diff --git a/app/assets/templates/directives/privileges-management-modal.html.haml b/app/assets/templates/directives/privileges-management-modal.html.haml index 95e897156..fb9654a05 100644 --- a/app/assets/templates/directives/privileges-management-modal.html.haml +++ b/app/assets/templates/directives/privileges-management-modal.html.haml @@ -27,14 +27,15 @@ .sk-p.sk-panel-row You will not be asked to authenticate until {{sessionExpirey}}. %a.sk-a.sk-panel-row.info{"ng-click" => "clearSession()"} Clear Session .sk-panel-footer - .sk-h2 About Privileges + .sk-h2.sk-bold About Privileges .sk-panel-section.no-bottom-pad - .text-content - %p - Privileges represent interface level authentication for accessing certain items and features. - Note that when your application is unlocked, your data exists in temporary memory in an unencrypted state. - Privileges are meant to protect against unwanted access in the event of an unlocked application, but do not affect data encryption state. - %p - Privileges sync across your other devices (not including mobile); however, note that if you require - a "Local Passcode" privilege, and another device does not have a local passcode set up, the local passcode - requirement will be ignored on that device. + .sk-panel-row + .text-content + .sk-p + Privileges represent interface level authentication for accessing certain items and features. + Note that when your application is unlocked, your data exists in temporary memory in an unencrypted state. + Privileges are meant to protect against unwanted access in the event of an unlocked application, but do not affect data encryption state. + %p.sk-p + Privileges sync across your other devices (not including mobile); however, note that if you require + a "Local Passcode" privilege, and another device does not have a local passcode set up, the local passcode + requirement will be ignored on that device.