Create LoginMethod for password login

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-07-30 13:34:25 +05:30
parent e0fcec9102
commit 20765d9688
2 changed files with 25 additions and 0 deletions

10
src/matrix/LoginMethod.js Normal file
View file

@ -0,0 +1,10 @@
export class LoginMethod {
constructor({homeServer, platform}) {
this.homeServer = homeServer;
this._platform = platform;
}
async login(hsApi, deviceName) {
throw("Not Implemented");
}
}

View file

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