Defer more auth logic to snjs
This commit is contained in:
@@ -17,7 +17,6 @@ export class PureCtrl {
|
|||||||
this.addAppStateObserver();
|
this.addAppStateObserver();
|
||||||
this.addAppEventObserver();
|
this.addAppEventObserver();
|
||||||
$scope.$on('$destroy', () => {
|
$scope.$on('$destroy', () => {
|
||||||
console.log("On destroy", this);
|
|
||||||
this.unsubApp();
|
this.unsubApp();
|
||||||
this.unsubState();
|
this.unsubState();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
|
console.log(" : AccountMenuCtrl -> close -> timeout");
|
||||||
this.props.closeFunction()();
|
this.props.closeFunction()();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -190,7 +191,8 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
});
|
});
|
||||||
const hasError = !response || response.error;
|
const hasError = !response || response.error;
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
await this.onAuthSuccess();
|
await this.setFormDataState({ authenticating: false });
|
||||||
|
this.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.setFormDataState({
|
await this.setFormDataState({
|
||||||
@@ -217,7 +219,7 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.setFormDataState({
|
await this.setFormDataState({
|
||||||
authenticating: false,
|
authenticating: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +256,8 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
text: error.message
|
text: error.message
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.onAuthSuccess();
|
await this.setFormDataState({ authenticating: false });
|
||||||
this.application.sync();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,17 +275,6 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAuthSuccess() {
|
|
||||||
if (this.state.formData.mergeLocal) {
|
|
||||||
this.$rootScope.$broadcast('major-data-change');
|
|
||||||
await this.rewriteDatabase({ alternateUuids: true });
|
|
||||||
}
|
|
||||||
await this.setFormDataState({
|
|
||||||
authenticating: false
|
|
||||||
});
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
openPasswordWizard(type) {
|
openPasswordWizard(type) {
|
||||||
this.close();
|
this.close();
|
||||||
this.godService.presentPasswordWizard(type);
|
this.godService.presentPasswordWizard(type);
|
||||||
@@ -309,17 +300,6 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows IndexedDB unencrypted logs to be deleted
|
|
||||||
* `clearAllPayloads` will remove data from backing store,
|
|
||||||
* but not from working memory See:
|
|
||||||
* https://github.com/standardnotes/desktop/issues/131
|
|
||||||
*/
|
|
||||||
async rewriteDatabase({ alternateUuids } = {}) {
|
|
||||||
await this.application.clearDatabase();
|
|
||||||
await this.application.markAllItemsAsNeedingSync({ alternateUuids });
|
|
||||||
}
|
|
||||||
|
|
||||||
destroyLocalData() {
|
destroyLocalData() {
|
||||||
this.application.alertManager.confirm({
|
this.application.alertManager.confirm({
|
||||||
text: STRING_SIGN_OUT_CONFIRMATION,
|
text: STRING_SIGN_OUT_CONFIRMATION,
|
||||||
@@ -503,10 +483,6 @@ class AccountMenuCtrl extends PureCtrl {
|
|||||||
confirmPasscode: null,
|
confirmPasscode: null,
|
||||||
showPasscodeForm: false
|
showPasscodeForm: false
|
||||||
});
|
});
|
||||||
if (isNullOrUndefined(await this.application.getUser())) {
|
|
||||||
this.$rootScope.$broadcast('major-data-change');
|
|
||||||
this.rewriteDatabase();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
539
dist/javascripts/app.js
vendored
539
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
2
package-lock.json
generated
2
package-lock.json
generated
@@ -14961,6 +14961,8 @@
|
|||||||
},
|
},
|
||||||
"sncrypto": {
|
"sncrypto": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/sncrypto/-/sncrypto-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-qCBIm7rzPpaIv1GQ0T5R7zDcHwLdYfCIpdIOrZP3PQlXhAb2h36ypaRfLC5stOQTCf3xtOU7o4Ht8pH5S+QfPw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/cli": {
|
"@babel/cli": {
|
||||||
"version": "7.7.5",
|
"version": "7.7.5",
|
||||||
|
|||||||
Reference in New Issue
Block a user