Add method to query login types

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-07-27 19:23:46 +05:30
parent 1e05d41294
commit e0fcec9102
3 changed files with 11 additions and 0 deletions

View file

@ -49,6 +49,7 @@ export class LoginViewModel extends ViewModel {
this._loadViewModel = this.track(new SessionLoadViewModel(this.childOptions({ this._loadViewModel = this.track(new SessionLoadViewModel(this.childOptions({
createAndStartSessionContainer: () => { createAndStartSessionContainer: () => {
this._sessionContainer = this._createSessionContainer(); this._sessionContainer = this._createSessionContainer();
this._sessionContainer.queryLogin(homeserver);
this._sessionContainer.startWithLogin(homeserver, username, password); this._sessionContainer.startWithLogin(homeserver, username, password);
return this._sessionContainer; return this._sessionContainer;
}, },

View file

@ -97,6 +97,12 @@ export class SessionContainer {
}); });
} }
async queryLogin(homeServer) {
homeServer = normalizeHomeserver(homeServer);
const hsApi = new HomeServerApi({homeServer, request: this._platform.request});
const response = hsApi.queryLogin();
}
async startWithLogin(homeServer, username, password) { async startWithLogin(homeServer, username, password) {
if (this._status.get() !== LoadStatus.NotLoading) { if (this._status.get() !== LoadStatus.NotLoading) {
return; return;

View file

@ -134,6 +134,10 @@ export class HomeServerApi {
return this._get(`/rooms/${encodeURIComponent(roomId)}/state/${encodeURIComponent(eventType)}/${encodeURIComponent(stateKey)}`, {}, null, options); return this._get(`/rooms/${encodeURIComponent(roomId)}/state/${encodeURIComponent(eventType)}/${encodeURIComponent(stateKey)}`, {}, null, options);
} }
queryLogin() {
return this._unauthedRequest("GET", this._url("/login"), null, null, null);
}
passwordLogin(username, password, initialDeviceDisplayName, options = null) { passwordLogin(username, password, initialDeviceDisplayName, options = null) {
return this._unauthedRequest("POST", this._url("/login"), null, { return this._unauthedRequest("POST", this._url("/login"), null, {
"type": "m.login.password", "type": "m.login.password",