forked from jason/cpolis
Created package "calls" and verification for frontend and calls
This commit is contained in:
@@ -7,8 +7,12 @@ import (
|
||||
b "streifling.com/jason/cpolis/cmd/backend"
|
||||
)
|
||||
|
||||
func CreateTag(c *b.Config) http.HandlerFunc {
|
||||
func CreateTag(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if _, err := getSession(w, r, c, s); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-tag.html")
|
||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
||||
}
|
||||
@@ -16,15 +20,13 @@ func CreateTag(c *b.Config) http.HandlerFunc {
|
||||
|
||||
func AddTag(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
db.AddTag(r.PostFormValue("tag"))
|
||||
|
||||
session, err := s.Get(r, "cookie")
|
||||
session, err := getSession(w, r, c, s)
|
||||
if err != nil {
|
||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/login.html")
|
||||
msg := "Session nicht mehr gültig. Bitte erneut anmelden."
|
||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", msg)
|
||||
return
|
||||
}
|
||||
|
||||
db.AddTag(r.PostFormValue("tag"))
|
||||
|
||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||
tmpl = template.Must(tmpl, err)
|
||||
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||
|
||||
Reference in New Issue
Block a user