From e0fcec910220bfb9965b1f0c1ae6e91a93f414f9 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 27 Jul 2021 19:23:46 +0530 Subject: [PATCH] Add method to query login types Signed-off-by: RMidhunSuresh --- src/domain/LoginViewModel.js | 1 + src/matrix/SessionContainer.js | 6 ++++++ src/matrix/net/HomeServerApi.js | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/domain/LoginViewModel.js b/src/domain/LoginViewModel.js index 1b52e1a5..9e1db503 100644 --- a/src/domain/LoginViewModel.js +++ b/src/domain/LoginViewModel.js @@ -49,6 +49,7 @@ export class LoginViewModel extends ViewModel { this._loadViewModel = this.track(new SessionLoadViewModel(this.childOptions({ createAndStartSessionContainer: () => { this._sessionContainer = this._createSessionContainer(); + this._sessionContainer.queryLogin(homeserver); this._sessionContainer.startWithLogin(homeserver, username, password); return this._sessionContainer; }, diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 07c4a870..1106644c 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -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) { if (this._status.get() !== LoadStatus.NotLoading) { return; diff --git a/src/matrix/net/HomeServerApi.js b/src/matrix/net/HomeServerApi.js index a9b63f8e..6dec6bd6 100644 --- a/src/matrix/net/HomeServerApi.js +++ b/src/matrix/net/HomeServerApi.js @@ -134,6 +134,10 @@ export class HomeServerApi { 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) { return this._unauthedRequest("POST", this._url("/login"), null, { "type": "m.login.password",