mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
clean: made pageError struct type
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
<form action="login" class="" method="POST">
|
||||
<div class="d-flex flex-column gap-4">
|
||||
<div class="form-floating">
|
||||
<input class="form-control {{ if .IsError }} is-invalid {{ end }}"
|
||||
<input class="form-control {{ if .PageError.IsError }} is-invalid {{ end }}"
|
||||
id="username"
|
||||
name="username"
|
||||
placeholder="Nom d'utilisateur"
|
||||
@@ -33,14 +33,14 @@
|
||||
<label for="username">Nom d'utilisateur</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input class="form-control {{ if .IsError }} is-invalid {{ end }}"
|
||||
<input class="form-control {{ if .PageError.IsError }} is-invalid {{ end }}"
|
||||
id="password"
|
||||
name="password"
|
||||
placeholder="Mot de passe"
|
||||
required
|
||||
type="password">
|
||||
<label for="password">Mot de passe</label>
|
||||
<div class="invalid-feedback">{{.Error}}</div>
|
||||
<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"
|
||||
|
||||
@@ -21,6 +21,11 @@ var contentTypes = map[string]string{
|
||||
".ico": "image/x-icon",
|
||||
}
|
||||
|
||||
type PageError struct {
|
||||
Message string `json:"message"`
|
||||
IsError bool `json:"isError"`
|
||||
}
|
||||
|
||||
func StaticFileServerWithContentType(fsys http.FileSystem) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
|
||||
+6
-5
@@ -11,15 +11,16 @@ import (
|
||||
const LoginRoute = "/login"
|
||||
|
||||
type LoginPage struct {
|
||||
IsError bool `json:"isError"`
|
||||
Error string `json:"error"`
|
||||
Username string `json:"username"`
|
||||
PageError *PageError `json:"error"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
func NewLoginPage(error string, username string) *LoginPage {
|
||||
return &LoginPage{
|
||||
IsError: strings.Compare(error, "") != 0,
|
||||
Error: error,
|
||||
PageError: &PageError{
|
||||
IsError: strings.Compare(error, "") != 0,
|
||||
Message: error,
|
||||
},
|
||||
Username: username,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user