Default auth params version value, SFJS 0.3.6

This commit is contained in:
Mo Bitar
2018-07-23 08:45:04 -05:00
parent cd3d5891c1
commit e4da258d46
4 changed files with 15 additions and 21 deletions

View File

@@ -23,7 +23,17 @@ angular.module('app')
}
this.passcodeAuthParams = function() {
return JSON.parse(storageManager.getItemSync("offlineParams", StorageManager.Fixed));
var authParams = JSON.parse(storageManager.getItemSync("offlineParams", StorageManager.Fixed));
if(authParams && !authParams.version) {
var keys = this.keys();
if(keys && keys.ak) {
// If there's no version stored, and there's an ak, it has to be 002. Newer versions would have thier version stored in authParams.
authParams.version = "002";
} else {
authParams.version = "001";
}
}
return authParams;
}
this.unlock = function(passcode, callback) {
@@ -58,7 +68,6 @@ angular.module('app')
// Encrypting will initially clear localStorage
this.encryptLocalStorage(keys, authParams);
// After it's cleared, it's safe to write to it
storageManager.setItem("offlineParams", JSON.stringify(authParams), StorageManager.Fixed);
callback(true);