aboutsummaryrefslogtreecommitdiff
path: root/pim_http.go
diff options
context:
space:
mode:
Diffstat (limited to 'pim_http.go')
-rw-r--r--pim_http.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/pim_http.go b/pim_http.go
new file mode 100644
index 0000000..e04c702
--- /dev/null
+++ b/pim_http.go
@@ -0,0 +1,46 @@
+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)
+}