Convert PasswordLoginMethod to ts

This commit is contained in:
RMidhunSuresh 2021-11-24 13:47:26 +05:30
parent 91f2a96403
commit e4c443c73a
2 changed files with 14 additions and 8 deletions

View file

@ -19,5 +19,5 @@ import type {HomeServerApi} from "../net/HomeServerApi.js";
export interface ILoginMethod { export interface ILoginMethod {
homeserver: string; homeserver: string;
login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Response["body"]; login(hsApi: HomeServerApi, deviceName: string, log: ILogItem): Promise<Response["body"]>;
} }

View file

@ -14,16 +14,22 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {LoginMethod} from "./LoginMethod"; import {ILogItem} from "../../logging/types";
import {ILoginMethod} from "./LoginMethod";
import {HomeServerApi} from "../net/HomeServerApi.js";
export class PasswordLoginMethod extends LoginMethod { export class PasswordLoginMethod implements ILoginMethod {
constructor(options) { public username: string;
super(options); public password: string;
this.username = options.username; public homeserver: string;
this.password = options.password;
constructor({username, password, homeserver}: {username: string, password: string, homeserver: string}) {
this.username = username;
this.password = password;
this.homeserver = homeserver;
} }
async login(hsApi, deviceName, log) { async login(hsApi: HomeServerApi, deviceName: string, log: ILogItem) {
return await hsApi.passwordLogin(this.username, this.password, deviceName, {log}).response(); return await hsApi.passwordLogin(this.username, this.password, deviceName, {log}).response();
} }
} }