Skip to content

Commit

Permalink
Handle unsecured android devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremiah Ogbomo authored and smarki committed Aug 14, 2019
1 parent 191c9ca commit fdb6a12
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/www/scripts/secure-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ module.exports = (function() {
var getStorage = function(namespace) {
if (!namespacePromises[namespace]) {
namespacePromises[namespace] = new Promise(function (resolve, reject) {
var storage = new cordova.plugins.SecureStorage(function () {
resolve(storage);
}, reject, namespace);
var storage = new cordova.plugins.SecureStorage(
function () {
resolve(storage);
},
function(error) {
if (error.message === "Device is not secure") {
var retry = function () {
resolve(getStorage());
}
return navigator.notification.alert(
"Please enable the screen lock on your device. This app cannot operate securely without it.",
function () {
storage.secureDevice(retry, retry);
},
"Screen lock is disabled"
);
}

reject(e);
},
namespace
);
});
}

Expand Down

0 comments on commit fdb6a12

Please sign in to comment.