mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
109 lines
3.6 KiB
HTML
109 lines
3.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>RenewCMS | Login</title>
|
|
{{.Head}}
|
|
|
|
<style>
|
|
.form-container {
|
|
max-width: 24rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="d-flex min-vh-100 vw-100 justify-content-center align-items-center text-dark">
|
|
<div class="container">
|
|
<div class="d-flex flex-column m-auto form-container">
|
|
<div>
|
|
<h1>RenewCMS</h1>
|
|
<h2>Login</h2>
|
|
</div>
|
|
<form action="login" method="POST" class="mt-5" id="loginForm">
|
|
<div class="d-flex flex-column gap-4">
|
|
<div class="form-floating">
|
|
<input class="form-control {{ if .PageError.IsError }} is-invalid {{ end }}"
|
|
id="username"
|
|
name="username"
|
|
placeholder="Username"
|
|
required
|
|
type="text"
|
|
value="{{.Username}}">
|
|
<label for="username">Username</label>
|
|
</div>
|
|
<div class="form-floating">
|
|
<input class="form-control {{ if .PageError.IsError }} is-invalid {{ end }}"
|
|
id="password"
|
|
name="password"
|
|
placeholder="Password"
|
|
required
|
|
type="password">
|
|
<label for="password">Password</label>
|
|
<div class="invalid-feedback">{{.PageError.Message}}</div>
|
|
</div>
|
|
<button id="loginFormButton" class="btn btn-primary" disabled type="submit">
|
|
<span class="loginFormButtonLoading visually-hidden spinner-border spinner-border-sm"
|
|
role="status"></span>
|
|
<span class="loginFormButtonDefault">Log in</span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<div class="d-flex gap-2 my-2 w-100">
|
|
<a href="register" class="btn btn-outline-secondary w-100" type="submit">
|
|
First setup? Register
|
|
</a>
|
|
<a href="register/reset/request" class="btn btn-outline-secondary w-100" type="submit">
|
|
Forgot password
|
|
</a>
|
|
</div>
|
|
{{ if .Success }}
|
|
<div class="alert alert-success my-4" role="alert">
|
|
{{ .Success }}
|
|
</div>
|
|
{{ else if .Failure }}
|
|
<div class="alert alert-danger my-4" role="alert">
|
|
{{ .Failure }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const button = document.querySelector("#loginFormButton")
|
|
const inputs = document.querySelectorAll('input')
|
|
const form = document.querySelector("#loginForm")
|
|
|
|
function formFieldsEmpty() {
|
|
return Array.from(inputs).some((input) => input.value === "")
|
|
}
|
|
|
|
function isFormValid() {
|
|
return !formFieldsEmpty() && validateEmail()
|
|
}
|
|
|
|
function setButtonDisabled() {
|
|
button.disabled = isFormValid() ? "disabled" : ""
|
|
}
|
|
|
|
function setButtonLoading() {
|
|
button.classList.add("disabled")
|
|
button.querySelector(".loginFormButtonDefault").classList.add("visually-hidden")
|
|
button.querySelector(".loginFormButtonLoading").classList.remove("visually-hidden")
|
|
}
|
|
|
|
function onLoginFormSubmit(event) {
|
|
event.preventDefault()
|
|
setButtonLoading()
|
|
event.target.submit()
|
|
}
|
|
|
|
function onInput(event) {
|
|
if (event.target.tagName === "INPUT") setButtonDisabled()
|
|
}
|
|
|
|
form.addEventListener('submit', onLoginFormSubmit)
|
|
window.addEventListener('input', onInput)
|
|
setButtonDisabled()
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|