Quentin Dufour
aff7efd726
Some checks reported errors
continuous-integration/drone/push Build was killed
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package main
|
|
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
type PimInspectView struct {
|
|
User *LoggedUser
|
|
Debug string
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
view := PimInspectView {
|
|
User: user,
|
|
Debug: string(pim_json),
|
|
}
|
|
|
|
tKey := getTemplate("pim_inspect.html")
|
|
tKey.Execute(w, view)
|
|
}
|
|
|
|
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)
|
|
}
|