Repository: incubator-milagro-mfa-js-lib
Updated Branches:
  refs/heads/mpin-without-qr [created] 50921c7e4


Make initialisation of local storage

This should fix several problems


Project: 
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/50921c7e
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/50921c7e
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/50921c7e

Branch: refs/heads/mpin-without-qr
Commit: 50921c7e42064ee88b32226752f57be671e5603e
Parents: 1914a96
Author: Pavlin Angelov <[email protected]>
Authored: Mon Nov 7 17:21:17 2016 +0200
Committer: Pavlin Angelov <[email protected]>
Committed: Mon Nov 7 18:10:29 2016 +0200

----------------------------------------------------------------------
 lib/mpin.js | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/50921c7e/lib/mpin.js
----------------------------------------------------------------------
diff --git a/lib/mpin.js b/lib/mpin.js
index 70cb32c..e45be1d 100644
--- a/lib/mpin.js
+++ b/lib/mpin.js
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -55,6 +55,16 @@ var mpinjs = (function () {
     var self = this, _initUrl;
 
     this.recover();
+
+    var mpinData = this.getData();
+    if (!mpinData) {
+      mpinData = {
+        version: "4",
+        accounts: {}
+      };
+      this.storeData(mpinData);
+    }
+
     if (this.opts.server.slice(-1) === "/") {
       _initUrl = this.opts.server;
     } else {
@@ -796,15 +806,7 @@ var mpinjs = (function () {
   Mpin.prototype.setData = function (userId, upData) {
     var mpinData = this.getData();
 
-    if (!mpinData) {
-      mpinData = {
-        version: "4",
-        accounts: {}
-      };
-    }
-
     var mpinId = upData.mpinId || Users[userId].mpinId;
-
     if (!mpinId) {
       return false;
     }

Reply via email to