From 20765d96885948abe9f163ec4a962edeb46ab1e9 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 30 Jul 2021 13:34:25 +0530 Subject: [PATCH] Create LoginMethod for password login Signed-off-by: RMidhunSuresh --- src/matrix/LoginMethod.js | 10 ++++++++++ src/matrix/PasswordLoginMethod.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/matrix/LoginMethod.js create mode 100644 src/matrix/PasswordLoginMethod.js diff --git a/src/matrix/LoginMethod.js b/src/matrix/LoginMethod.js new file mode 100644 index 00000000..0d57499e --- /dev/null +++ b/src/matrix/LoginMethod.js @@ -0,0 +1,10 @@ +export class LoginMethod { + constructor({homeServer, platform}) { + this.homeServer = homeServer; + this._platform = platform; + } + + async login(hsApi, deviceName) { + throw("Not Implemented"); + } +} diff --git a/src/matrix/PasswordLoginMethod.js b/src/matrix/PasswordLoginMethod.js new file mode 100644 index 00000000..81f2204f --- /dev/null +++ b/src/matrix/PasswordLoginMethod.js @@ -0,0 +1,15 @@ +import { LoginMethod } from "./LoginMethod.js"; + +export class PasswordLoginMethod extends LoginMethod { + constructor(options) { + super(options); + this.username = options.username; + this.password = options.password; + } + + async login(hsApi, deviceName) { + return this._platform.logger.run("passwordLogin", async log => + await hsApi.passwordLogin(this.username, this.password, deviceName, {log}).response() + ); + } +}