sync status, show credentials
This commit is contained in:
@@ -79,7 +79,7 @@ angular.module('app.frontend')
|
||||
var params = {password: keys.pw, email: email};
|
||||
_.merge(request, params);
|
||||
request.post().then(function(response){
|
||||
this.handleAuthResponse(response, email, url, authParams, mk);
|
||||
this.handleAuthResponse(response, email, url, authParams, mk, keys.pw);
|
||||
callback(response);
|
||||
}.bind(this))
|
||||
.catch(function(response){
|
||||
@@ -90,11 +90,12 @@ angular.module('app.frontend')
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
this.handleAuthResponse = function(response, email, url, authParams, mk) {
|
||||
this.handleAuthResponse = function(response, email, url, authParams, mk, pw) {
|
||||
localStorage.setItem("server", url);
|
||||
localStorage.setItem("user", JSON.stringify(response.plain().user));
|
||||
localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"])));
|
||||
localStorage.setItem("mk", mk);
|
||||
localStorage.setItem("pw", pw);
|
||||
localStorage.setItem("jwt", response.token);
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ angular.module('app.frontend')
|
||||
var params = _.merge({password: keys.pw, email: email}, authParams);
|
||||
_.merge(request, params);
|
||||
request.post().then(function(response){
|
||||
this.handleAuthResponse(response, email, url, authParams, mk);
|
||||
this.handleAuthResponse(response, email, url, authParams, mk, keys.pw);
|
||||
callback(response);
|
||||
}.bind(this))
|
||||
.catch(function(response){
|
||||
|
||||
@@ -19,6 +19,14 @@ class AccountMenu {
|
||||
$scope.showNewPasswordForm = !$scope.showNewPasswordForm;
|
||||
}
|
||||
|
||||
$scope.encryptionKey = function() {
|
||||
return syncManager.masterKey;
|
||||
}
|
||||
|
||||
$scope.serverPassword = function() {
|
||||
return syncManager.serverPassword;
|
||||
}
|
||||
|
||||
$scope.submitPasswordChange = function() {
|
||||
$scope.passwordChangeData.status = "Generating New Keys...";
|
||||
|
||||
@@ -108,10 +116,10 @@ class AccountMenu {
|
||||
$scope.importData.loading = true;
|
||||
// allow loading indicator to come up with timeout
|
||||
$timeout(function(){
|
||||
$scope.importJSONData(data, password, function(success, response){
|
||||
$scope.importJSONData(data, password, function(response){
|
||||
// console.log("Import response:", success, response);
|
||||
$scope.importData.loading = false;
|
||||
if(success) {
|
||||
if(response) {
|
||||
$scope.importData = null;
|
||||
} else {
|
||||
alert("There was an error importing your data. Please try again.");
|
||||
|
||||
@@ -17,6 +17,10 @@ class SyncManager {
|
||||
return localStorage.getItem("mk");
|
||||
}
|
||||
|
||||
get serverPassword() {
|
||||
return localStorage.getItem("pw");
|
||||
}
|
||||
|
||||
writeItemsToLocalStorage(items, offlineOnly, callback) {
|
||||
var params = items.map(function(item) {
|
||||
var itemParams = new ItemParams(item, null);
|
||||
@@ -49,7 +53,7 @@ class SyncManager {
|
||||
}.bind(this))
|
||||
|
||||
if(callback) {
|
||||
callback();
|
||||
callback({success: true});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +70,6 @@ class SyncManager {
|
||||
}
|
||||
|
||||
set syncToken(token) {
|
||||
console.log("setting token", token);
|
||||
this._syncToken = token;
|
||||
localStorage.setItem("syncToken", token);
|
||||
}
|
||||
@@ -78,6 +81,22 @@ class SyncManager {
|
||||
return this._syncToken;
|
||||
}
|
||||
|
||||
set cursorToken(token) {
|
||||
this._cursorToken = token;
|
||||
if(token) {
|
||||
localStorage.setItem("cursorToken", token);
|
||||
} else {
|
||||
localStorage.removeItem("cursorToken");
|
||||
}
|
||||
}
|
||||
|
||||
get cursorToken() {
|
||||
if(!this._cursorToken) {
|
||||
this._cursorToken = localStorage.getItem("cursorToken");
|
||||
}
|
||||
return this._cursorToken;
|
||||
}
|
||||
|
||||
sync(callback, options = {}) {
|
||||
|
||||
if(this.syncStatus.syncOpInProgress) {
|
||||
@@ -135,7 +154,6 @@ class SyncManager {
|
||||
|
||||
this.modelManager.clearDirtyItems(subItems);
|
||||
this.syncStatus.error = null;
|
||||
this.cursorToken = response.cursor_token;
|
||||
|
||||
this.$rootScope.$broadcast("sync:updated_token", this.syncToken);
|
||||
|
||||
@@ -154,6 +172,7 @@ class SyncManager {
|
||||
|
||||
// set the sync token at the end, so that if any errors happen above, you can resync
|
||||
this.syncToken = response.sync_token;
|
||||
this.cursorToken = response.cursor_token;
|
||||
|
||||
if(this.cursorToken || this.repeatOnCompletion || this.needsMoreSync) {
|
||||
setTimeout(function () {
|
||||
|
||||
Reference in New Issue
Block a user