38 lines
908 B
JavaScript
38 lines
908 B
JavaScript
|
import AbstractView from "../AbstractView.js";
|
||
|
import { client } from "../../index.js";
|
||
|
|
||
|
async function login()
|
||
|
{
|
||
|
let username = document.getElementById("username").value;
|
||
|
let password = document.getElementById("password").value;
|
||
|
|
||
|
let response = await client.login(username, password);
|
||
|
let errors = await response.json();
|
||
|
|
||
|
errors.user.forEach(error => {
|
||
|
console.log(error)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export default class extends AbstractView {
|
||
|
constructor(params) {
|
||
|
super(params);
|
||
|
this.setTitle("Login");
|
||
|
document.body.addEventListener("click", e => {
|
||
|
e.preventDefault();
|
||
|
if (e.target.type == "button")
|
||
|
{
|
||
|
login();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async getHtml() {
|
||
|
return `
|
||
|
<input type="text" id="username" placeholder="username">
|
||
|
<input type="password" id="password" placeholder="password">
|
||
|
<input type="button" value="login">
|
||
|
<span id="login_failed"></span>
|
||
|
`;
|
||
|
}
|
||
|
}
|