Refactoring into admin.go activate
This commit is contained in:
parent
0613a7ed6d
commit
e9adb8d0c0
3 changed files with 55 additions and 0 deletions
28
admin.go
28
admin.go
|
@ -45,6 +45,34 @@ type AdminUsersTplData struct {
|
||||||
Users EntryList
|
Users EntryList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
|
templateAdminActivateUsers := getTemplate("admin_activate.html")
|
||||||
|
login := checkAdminLogin(w, r)
|
||||||
|
if login == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
searchRequest := ldap.NewSearchRequest(
|
||||||
|
config.InvitationBaseDN,
|
||||||
|
ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
|
fmt.Sprintf("(&(objectClass=organizationalPerson))"),
|
||||||
|
[]string{config.UserNameAttr, "dn", "displayName", "givenName", "sn", "mail", "uid", "cn"},
|
||||||
|
nil)
|
||||||
|
|
||||||
|
sr, err := login.conn.Search(searchRequest)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := &AdminUsersTplData{
|
||||||
|
Login: login,
|
||||||
|
UserNameAttr: config.UserNameAttr,
|
||||||
|
UserBaseDN: config.UserBaseDN,
|
||||||
|
Users: EntryList(sr.Entries),
|
||||||
|
}
|
||||||
|
templateAdminActivateUsers.Execute(w, data)
|
||||||
|
}
|
||||||
|
|
||||||
func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
|
func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
templateAdminUsers := getTemplate("admin_users.html")
|
templateAdminUsers := getTemplate("admin_users.html")
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -61,6 +61,8 @@ func main() {
|
||||||
r.HandleFunc("/passwd", handlePasswd)
|
r.HandleFunc("/passwd", handlePasswd)
|
||||||
r.HandleFunc("/picture/{name}", handleDownloadPicture)
|
r.HandleFunc("/picture/{name}", handleDownloadPicture)
|
||||||
|
|
||||||
|
r.HandleFunc("/admin/activate", handleAdminActivateUsers)
|
||||||
|
|
||||||
r.HandleFunc("/directory/search", handleDirectorySearch)
|
r.HandleFunc("/directory/search", handleDirectorySearch)
|
||||||
r.HandleFunc("/directory", handleDirectory)
|
r.HandleFunc("/directory", handleDirectory)
|
||||||
|
|
||||||
|
|
25
templates/admin_activate.html
Normal file
25
templates/admin_activate.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{{define "title"}}Activer des utilisateurs |{{end}}
|
||||||
|
|
||||||
|
<table class="table mt-4">
|
||||||
|
<thead>
|
||||||
|
<th scope="col">Identifiant</th>
|
||||||
|
<th scope="col">Nom complet</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{with $root := .}}
|
||||||
|
{{range $user := $root.Users}}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/admin/ldap/{{$group.DN}}">
|
||||||
|
{{$user.GetAttributeValue $user.UserNameAttr}}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>{{$user.GetAttributeValue "mail"}}</td>
|
||||||
|
<td>{{$user.GetAttributeValue "displayname"}}</td>
|
||||||
|
<td>{{$user.GetAttributeValue "sn"}}</td>
|
||||||
|
<td>{{$user.GetAttributeValue "description"}}</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
Loading…
Reference in a new issue