Create LoginMethod for password login
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
e0fcec9102
commit
20765d9688
2 changed files with 25 additions and 0 deletions
10
src/matrix/LoginMethod.js
Normal file
10
src/matrix/LoginMethod.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
export class LoginMethod {
|
||||||
|
constructor({homeServer, platform}) {
|
||||||
|
this.homeServer = homeServer;
|
||||||
|
this._platform = platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
async login(hsApi, deviceName) {
|
||||||
|
throw("Not Implemented");
|
||||||
|
}
|
||||||
|
}
|
15
src/matrix/PasswordLoginMethod.js
Normal file
15
src/matrix/PasswordLoginMethod.js
Normal 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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue