Check correct login method early

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-17 20:54:24 +05:30
parent 83f4095d88
commit 13cb8979ac
2 changed files with 12 additions and 6 deletions

View File

@ -41,15 +41,18 @@ export class CompleteSSOLoginViewModel extends ViewModel {
}
const homeserver = await this.platform.settingsStorage.getString("sso_ongoing_login_homeserver");
const loginOptions = await this._sessionContainer.queryLogin(homeserver);
if (!loginOptions.token) {
const path = this.navigation.pathFrom([this.navigation.segment("session")]);
this.navigation.applyPath(path);
return;
}
this._loadViewModelSubscription = this.disposeTracked(this._loadViewModelSubscription);
if (this._loadViewModel) {
this._loadViewModel = this.disposeTracked(this._loadViewModel);
}
this._loadViewModel = this.track(new SessionLoadViewModel(this.childOptions({
createAndStartSessionContainer: async () => {
if (loginOptions.sso) {
this._sessionContainer.startWithLogin(loginOptions.token(this._loginToken));
}
this._sessionContainer.startWithLogin(loginOptions.token(this._loginToken));
return this._sessionContainer;
},
ready: this._ready,

View File

@ -49,15 +49,18 @@ export class PasswordLoginViewModel extends ViewModel {
}
async login(username, password, homeserver) {
if (!this._loginOptions.password) {
const path = this.navigation.pathFrom([this.navigation.segment("session")]);
this.navigation.applyPath(path);
return;
}
this._loadViewModelSubscription = this.disposeTracked(this._loadViewModelSubscription);
if (this._loadViewModel) {
this._loadViewModel = this.disposeTracked(this._loadViewModel);
}
this._loadViewModel = this.track(new SessionLoadViewModel(this.childOptions({
createAndStartSessionContainer: async () => {
if (this._loginOptions.password) {
this._sessionContainer.startWithLogin(this._loginOptions.password(username, password));
}
this._sessionContainer.startWithLogin(this._loginOptions.password(username, password));
return this._sessionContainer;
},
ready: this._ready,