From 890604b943952145dad5027467587ea1dea3603f Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Sat, 22 Jul 2023 08:03:22 +0200 Subject: [PATCH] Factoring the model user and correcting password --- login.go | 8 +++++++- model-user.go | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/login.go b/login.go index 6ec3479..5a8f74b 100644 --- a/login.go +++ b/login.go @@ -68,7 +68,13 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus { return nil } - err = l.Bind(login_info.DN, login_info.Password) + err = bind(User{ + DN: login_info.DN, + Password: login_info.Password, + }, config, l) + + // err = l.Bind(login_info.DN, login_info.Password) + if err != nil { delete(session.Values, "login_username") delete(session.Values, "login_password") diff --git a/model-user.go b/model-user.go index 02ae95f..44cfdff 100644 --- a/model-user.go +++ b/model-user.go @@ -98,6 +98,10 @@ func passwd(user User, config *ConfigFile, ldapConn *ldap.Conn) error { return err } +func bind(user User, config *ConfigFile, ldapConn *ldap.Conn) error { + return ldapConn.Bind(user.DN, user.Password) +} + func replaceIfContent(modifReq *ldap.ModifyRequest, key string, value string) error { if value != "" { modifReq.Replace(key, []string{value})