Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
web updates
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed May 24, 2017
1 parent 11c54b4 commit 3ee1488
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions app/js/compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -35735,11 +35735,11 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager);
return domain;
}

this.$get = function ($rootScope, httpManager, modelManager) {
return new AuthManager($rootScope, httpManager, modelManager);
this.$get = function ($rootScope, httpManager, modelManager, dbManager) {
return new AuthManager($rootScope, httpManager, modelManager, dbManager);
};

function AuthManager($rootScope, httpManager, modelManager) {
function AuthManager($rootScope, httpManager, modelManager, dbManager) {

var userData = localStorage.getItem("user");
if (userData) {
Expand Down Expand Up @@ -35769,7 +35769,11 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager);
};

this.keys = function () {
var keys = { mk: localStorage.getItem("mk") };
var mk = localStorage.getItem("mk");
if (!mk) {
return null;
}
var keys = { mk: mk };
if (!localStorage.getItem("encryptionKey")) {
_.merge(keys, Neeto.crypto.generateKeysFromMasterKey(keys.mk));
localStorage.setItem("encryptionKey", keys.encryptionKey);
Expand Down Expand Up @@ -35831,14 +35835,18 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager);
};

this.handleAuthResponse = function (response, email, url, authParams, mk, pw) {
if (url) {
localStorage.setItem("server", url);
}
localStorage.setItem("user", JSON.stringify(response.user));
localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"])));
localStorage.setItem("mk", mk);
localStorage.setItem("pw", pw);
localStorage.setItem("jwt", response.token);
try {
if (url) {
localStorage.setItem("server", url);
}
localStorage.setItem("user", JSON.stringify(response.user));
localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"])));
localStorage.setItem("mk", mk);
localStorage.setItem("pw", pw);
localStorage.setItem("jwt", response.token);
} catch (e) {
dbManager.displayOfflineAlert();
}
};

this.register = function (url, email, password, callback) {
Expand Down Expand Up @@ -35887,6 +35895,14 @@ var DBManager = function () {
}

_createClass(DBManager, [{
key: 'displayOfflineAlert',
value: function displayOfflineAlert() {
var message = "There was an issue loading your offline database. This could happen for two reasons:";
message += "\n\n1. You're in a private window in your browser. We can't save your data without access to the local database. Please use a non-private window.";
message += "\n\n2. You have two windows of the app open at the same time. Please close any other app instances and reload the page.";
alert(message);
}
}, {
key: 'openDatabase',
value: function openDatabase(callback, onUgradeNeeded) {
var request = window.indexedDB.open("standardnotes", 1);
Expand All @@ -35895,13 +35911,13 @@ var DBManager = function () {
if (event.target.errorCode) {
alert("Offline database issue: " + event.target.errorCode);
} else {
alert("There was an issue loading your offline database. This usually happens when you have two windows of the app open at the same time. Please close any other app instances and reload the page.");
this.displayOfflineAlert();
}
console.error("Offline database issue:", event);
if (callback) {
callback(null);
}
};
}.bind(this);

request.onsuccess = function (event) {
var db = event.target.result;
Expand Down

0 comments on commit 3ee1488

Please sign in to comment.