ringfinger/js/api/UserLoginApiRequest.ts

20 lines
571 B
TypeScript
Raw Normal View History

import ApiRequest from "./ApiRequest.js";
import RequestMethod from "./RequestMethod.js";
import UserLoginSuccessEvent from "../event/UserLoginSuccessEvent.js";
export default class UserLoginApiRequest extends ApiRequest
{
public constructor(username: string, password: string)
{
super('user/session', RequestMethod.POST);
this.addParameter('username', username);
this.addParameter('password', password);
this.onSuccess = (response: string) =>
{
let json = JSON.parse(response);
window.dispatchEvent(new UserLoginSuccessEvent(json.userId));
};
}
}