Added a way of disabling LDAP auth

This commit is contained in:
BetaPictoris
2023-08-06 00:40:26 -07:00
parent 6b2f853b3c
commit 6602495032
2 changed files with 10 additions and 5 deletions

No files matched your search

+1
View File
@@ -7,6 +7,7 @@
) }}
<form class="flex flex-col gap-2 items-end" action="{{ path
"/admin/ldap_do" }}" method="post">
<p>Leave the server empty to disable LDAP.</p>
<input
type="username"
id="bind_user"
+9 -5
View File
@@ -188,14 +188,11 @@ func (c *Controller) ServeLDAPConfigDo(r *http.Request) *Response {
tls := r.FormValue("tls")
baseDN := r.FormValue("base_dn")
filter := r.FormValue("filter")
log.Print("AHHH")
log.Print(tls)
if bindUID == "" || bindPSWD == "" || fqdn == "" || port == "" || baseDN == "" || filter == "" {
if bindUID == "" || bindPSWD == ""|| port == "" || baseDN == "" || filter == "" {
return &Response{
redirect: r.Referer(),
flashW: []string{"please provide a bind username and password, a FQDN, port, base CN, and filter"},
flashW: []string{"please provide a bind username and password, port, base CN, and filter"},
}
}
@@ -208,6 +205,13 @@ func (c *Controller) ServeLDAPConfigDo(r *http.Request) *Response {
c.DB.SetSetting("ldap_base_dn", baseDN)
c.DB.SetSetting("ldap_filter", filter)
if fqdn == "" {
return &Response{
redirect: "/admin/home",
flashW: []string{"LDAP server was left empty, LDAP authentication will be disabled."},
}
}
return &Response{redirect: "/admin/home"}
}