aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/main.go b/main.go
index da59552..0a8e2da 100644
--- a/main.go
+++ b/main.go
@@ -309,6 +309,8 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
type LoginFormData struct {
Username string
+ WrongUser bool
+ WrongPass bool
ErrorMessage string
}
@@ -335,10 +337,17 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
err := l.Bind(user_dn, password)
if err != nil {
- templateLogin.Execute(w, LoginFormData{
- Username: username,
- ErrorMessage: err.Error(),
- })
+ data := &LoginFormData{
+ Username: username,
+ }
+ if ldap.IsErrorWithCode(err, ldap.LDAPResultInvalidCredentials) {
+ data.WrongPass = true
+ } else if ldap.IsErrorWithCode(err, ldap.LDAPResultNoSuchObject) {
+ data.WrongUser = true
+ } else {
+ data.ErrorMessage = err.Error()
+ }
+ templateLogin.Execute(w, data)
return nil
}