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 {
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.
*/
import {LoginMethod} from "./LoginMethod";
import {ILogItem} from "../../logging/types";
import {ILoginMethod} from "./LoginMethod";
import {HomeServerApi} from "../net/HomeServerApi.js";
export class PasswordLoginMethod extends LoginMethod {
constructor(options) {
super(options);
this.username = options.username;
this.password = options.password;
export class PasswordLoginMethod implements ILoginMethod {
public username: string;
public password: string;
public homeserver: string;
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();
}
}