Implementing Activate User

This commit is contained in:
Chris Mann 2023-07-21 07:38:12 +02:00
parent f00f59ce0b
commit e44b81729a
3 changed files with 25 additions and 1 deletions

View file

@ -89,6 +89,20 @@ func handleAdminActivateUser(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/admin/ldap/"+"cn="+cn+","+config.UserBaseDN, http.StatusFound) http.Redirect(w, r, "/admin/ldap/"+"cn="+cn+","+config.UserBaseDN, http.StatusFound)
} }
func handleAdminUnactivateUser(w http.ResponseWriter, r *http.Request) {
cn := mux.Vars(r)["cn"]
login := checkAdminLogin(w, r)
if login == nil {
return
}
modifyRequest := *ldap.NewModifyDNRequest("cn="+cn+","+config.UserBaseDN, "cn="+cn, true, config.InvitationBaseDN)
err := login.conn.ModifyDN(&modifyRequest)
if err != nil {
return
}
http.Redirect(w, r, "/admin/ldap/"+"cn="+cn+","+config.UserBaseDN, http.StatusFound)
}
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")

View file

@ -3,6 +3,7 @@
{{define "body"}} {{define "body"}}
<table class="table mt-4"> <table class="table mt-4">
<thead> <thead>
<th scope="col"></th>
<th scope="col">Login</th> <th scope="col">Login</th>
<th scope="col">Email</th> <th scope="col">Email</th>
<th scope="col">Nom d'ffichage</th> <th scope="col">Nom d'ffichage</th>
@ -16,9 +17,12 @@
<tr> <tr>
<td> <td>
<a href="/admin/activate/{{ $user.GetAttributeValue "cn" }}"> <a href="/admin/activate/{{ $user.GetAttributeValue "cn" }}">
{{$user.GetAttributeValue "cn"}} Activer
</a> </a>
</td> </td>
<td>
{{$user.GetAttributeValue "cn"}}
</td>
<td>{{$user.GetAttributeValue "mail"}}</td> <td>{{$user.GetAttributeValue "mail"}}</td>
<td>{{$user.GetAttributeValue "displayName"}}</td> <td>{{$user.GetAttributeValue "displayName"}}</td>
<td>{{$user.GetAttributeValue "givenName"}}</td> <td>{{$user.GetAttributeValue "givenName"}}</td>

View file

@ -10,6 +10,7 @@
<table class="table mt-4"> <table class="table mt-4">
<thead> <thead>
<th scope="col"></th>
<th scope="col">Identifiant</th> <th scope="col">Identifiant</th>
<th scope="col">Nom complet</th> <th scope="col">Nom complet</th>
<th scope="col">Email</th> <th scope="col">Email</th>
@ -18,6 +19,11 @@
{{with $root := .}} {{with $root := .}}
{{range $user := $root.Users}} {{range $user := $root.Users}}
<tr> <tr>
<td>
<a href="/admin/unactivate/{{ $user.GetAttributeValue "cn" }}">
Dèsactiver
</a>
</td>
<td> <td>
<a href="/admin/ldap/{{$user.DN}}"> <a href="/admin/ldap/{{$user.DN}}">
{{$user.GetAttributeValue $root.UserNameAttr}} {{$user.GetAttributeValue $root.UserNameAttr}}