fix auto-signin
This commit is contained in:
@@ -53,11 +53,11 @@ class RootCtrl {
|
|||||||
this.passcodeManager = passcodeManager;
|
this.passcodeManager = passcodeManager;
|
||||||
|
|
||||||
this.defineRootScopeFunctions();
|
this.defineRootScopeFunctions();
|
||||||
this.handleAutoSignInFromParams();
|
|
||||||
this.initializeStorageManager();
|
this.initializeStorageManager();
|
||||||
this.addAppStateObserver();
|
this.addAppStateObserver();
|
||||||
this.addDragDropHandlers();
|
|
||||||
this.defaultLoad();
|
this.defaultLoad();
|
||||||
|
this.handleAutoSignInFromParams();
|
||||||
|
this.addDragDropHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
defineRootScopeFunctions() {
|
defineRootScopeFunctions() {
|
||||||
@@ -289,45 +289,36 @@ class RootCtrl {
|
|||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAutoSignInFromParams() {
|
async handleAutoSignInFromParams() {
|
||||||
const urlParam = (key) => {
|
const params = this.$location.search();
|
||||||
return this.$location.search()[key];
|
const server = params['server'];
|
||||||
};
|
const email = params['email'];
|
||||||
|
const password = params['pw'];
|
||||||
|
console.log(server, email, password);
|
||||||
|
if (!server || !email || !password) return;
|
||||||
|
|
||||||
const autoSignInFromParams = async () => {
|
if (this.authManager.offline()) {
|
||||||
const server = urlParam('server');
|
const { error } = await this.authManager.login(
|
||||||
const email = urlParam('email');
|
server,
|
||||||
const pw = urlParam('pw');
|
email,
|
||||||
if(!this.authManager.offline()) {
|
password,
|
||||||
if(
|
false,
|
||||||
await this.syncManager.getServerURL() === server
|
false,
|
||||||
&& this.authManager.user.email === email
|
{}
|
||||||
) {
|
);
|
||||||
/** Already signed in, return */
|
if (!error) {
|
||||||
// eslint-disable-next-line no-useless-return
|
window.location.reload();
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
/** Sign out */
|
|
||||||
this.authManager.signout(true).then(() => {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.authManager.login(
|
|
||||||
server,
|
|
||||||
email,
|
|
||||||
pw,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
{}
|
|
||||||
).then((response) => {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
} else if (
|
||||||
|
this.authManager.user.email === email &&
|
||||||
if(urlParam('server')) {
|
(await this.syncManager.getServerURL()) === server
|
||||||
autoSignInFromParams();
|
) {
|
||||||
|
/** Already signed in, return */
|
||||||
|
// eslint-disable-next-line no-useless-return
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.authManager.signout(true);
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user