Do not render a different view when user is found
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
This commit is contained in:
parent
48526f6aca
commit
b319421c1f
2 changed files with 5 additions and 14 deletions
9
main.go
9
main.go
|
@ -237,8 +237,6 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||||
// --- Login Controller ---
|
// --- Login Controller ---
|
||||||
type LoginFormData struct {
|
type LoginFormData struct {
|
||||||
Username string
|
Username string
|
||||||
WrongUser bool
|
|
||||||
WrongPass bool
|
|
||||||
ErrorMessage string
|
ErrorMessage string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,10 +264,9 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &LoginFormData{
|
data := &LoginFormData{
|
||||||
Username: username,
|
Username: username,
|
||||||
}
|
}
|
||||||
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {
|
if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) ||
|
||||||
data.WrongPass = true
|
ldap.IsErrorWithCode(err, ldap.LDAPResultNoSuchObject) {
|
||||||
} else if ldap.IsErrorWithCode(err, ldap.LDAPResultNoSuchObject) {
|
data.ErrorMessage = "Le mot de passe et identifiant ne correspondent pas."
|
||||||
data.WrongUser = true
|
|
||||||
} else {
|
} else {
|
||||||
data.ErrorMessage = err.Error()
|
data.ErrorMessage = err.Error()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,9 @@
|
||||||
<h4>S'identifier</h4>
|
<h4>S'identifier</h4>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{{if .WrongUser}}
|
{{ with .ErrorMessage}}
|
||||||
<div class="alert alert-danger">Identifiant invalide.</div>
|
|
||||||
{{end}}
|
|
||||||
{{if .WrongPass}}
|
|
||||||
<div class="alert alert-danger">Mot de passe invalide.</div>
|
|
||||||
{{end}}
|
|
||||||
{{if .ErrorMessage}}
|
|
||||||
<div class="alert alert-danger">Impossible de se connecter.
|
<div class="alert alert-danger">Impossible de se connecter.
|
||||||
<div style="font-size: 0.8em">{{ .ErrorMessage }}</div>
|
<div style="font-size: 0.8em">{{ . }}</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Add table
Reference in a new issue