forked from Deuxfleurs/guichet
46 lines
971 B
Go
46 lines
971 B
Go
package main
|
|
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func handlePimInspect(w http.ResponseWriter, r *http.Request) {
|
|
user := RequireUserHtml(w, r)
|
|
if user == nil {
|
|
return
|
|
}
|
|
|
|
pim_ctl, err := NewPimBuilder(user).CheckCryptoRoot().CheckBucket().Build()
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
pim_json, err := json.MarshalIndent(pim_ctl, "", " ")
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
tKey := getTemplate("pim_inspect.html")
|
|
tKey.Execute(w, string(pim_json))
|
|
}
|
|
|
|
func handlePimSetup(w http.ResponseWriter, r *http.Request) {
|
|
user := RequireUserHtml(w, r)
|
|
if user == nil {
|
|
return
|
|
}
|
|
|
|
_, err := NewPimBuilder(user).CheckCryptoRoot().CheckBucket().LdapUpdate().Build()
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
user.Capabilities.CanUseEmail = true
|
|
|
|
|
|
http.Redirect(w, r, "/pim/inspect", http.StatusFound)
|
|
}
|