private browsing error alert
This commit is contained in:
@@ -7,11 +7,11 @@ angular.module('app.frontend')
|
||||
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) {
|
||||
@@ -41,7 +41,11 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -106,14 +110,18 @@ angular.module('app.frontend')
|
||||
}
|
||||
|
||||
this.handleAuthResponse = function(response, email, url, authParams, mk, pw) {
|
||||
if(url) {
|
||||
localStorage.setItem("server", url);
|
||||
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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
this.register = function(url, email, password, callback) {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
class DBManager {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
openDatabase(callback, onUgradeNeeded) {
|
||||
var request = window.indexedDB.open("standardnotes", 1);
|
||||
|
||||
@@ -7,13 +14,13 @@ class DBManager {
|
||||
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 = (event) => {
|
||||
var db = event.target.result;
|
||||
|
||||
Reference in New Issue
Block a user