{"size": 751, "ext": "js", "max_stars_repo_path": "client/static/index.js", "max_stars_repo_name": "zwade/pgui", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/static/index.js", "max_issues_repo_name": "zwade/pgui", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/static/index.js", "max_forks_repo_name": "zwade/pgui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.652173913, "max_line_length": 77, "alphanum_fraction": 0.499334221}
window.addEventListener("load", () => {
    document.querySelector("#login-form").addEventListener("submit", (e) => {
        let username = document.querySelector("#login-username").value;
        let password = document.querySelector("#login-password").value;

        fetch("/login", {
            method: "POST",
            credentials: "include",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify({ username, password }),
        }).then((result) => {
            if (result.status === 401) {
                alert("Bad credentials");
            } else {
                window.location.href = result.url;
            }
        })

        e.preventDefault();
    });
});