aboutsummaryrefslogtreecommitdiff
path: root/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'web.go')
-rw-r--r--web.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/web.go b/web.go
index 83d3283..9983855 100644
--- a/web.go
+++ b/web.go
@@ -3,13 +3,13 @@ package main
import (
"crypto/rand"
"html/template"
- "log"
"net/http"
"strconv"
"strings"
"github.com/gorilla/mux"
"github.com/gorilla/sessions"
+ log "github.com/sirupsen/logrus"
"golang.org/x/crypto/argon2"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
@@ -310,4 +310,28 @@ func configForm(w http.ResponseWriter, r *http.Request,
}
func handleDelete(w http.ResponseWriter, r *http.Request) {
+ templateDelete := template.Must(template.ParseFiles("templates/layout.html", "templates/delete.html"))
+
+ login := checkLogin(w, r)
+ if login == nil {
+ return
+ }
+
+ account := mux.Vars(r)["account"]
+
+ if r.Method == "POST" {
+ r.ParseForm()
+ del := strings.Join(r.Form["delete"], "")
+ if del == "Yes" {
+ RemoveAccount(login.MxId, account)
+ db.Where(&DbAccountConfig{
+ MxUserID: login.MxId,
+ Name: account,
+ }).Delete(&DbAccountConfig{})
+ http.Redirect(w, r, "/", http.StatusFound)
+ return
+ }
+ }
+
+ templateDelete.Execute(w, account)
}