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() + ); + } +}