Fix cookie banner
parent
adf485bb46
commit
3c438b0ee2
|
@ -12,6 +12,7 @@ func AboutHandler(app *App) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value("session").(*sessions.Session)
|
||||
loggedIn := session.Values["user_id"] != nil
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
|
||||
aboutContent, err := ioutil.ReadFile("config/about.template")
|
||||
if err != nil {
|
||||
|
@ -28,7 +29,7 @@ func AboutHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - About",
|
||||
Navbar: "about",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
|
@ -13,6 +13,7 @@ func BoardHandler(app *App) http.HandlerFunc {
|
|||
session := r.Context().Value("session").(*sessions.Session)
|
||||
loggedIn := session.Values["user_id"] != nil
|
||||
userID, _ := session.Values["user_id"].(int)
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
|
||||
boardIDStr := r.URL.Query().Get("id")
|
||||
boardID, err := strconv.Atoi(boardIDStr)
|
||||
|
@ -110,7 +111,7 @@ func BoardHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - " + board.Name,
|
||||
Navbar: "boards",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
|
@ -12,6 +12,7 @@ func BoardsHandler(app *App) http.HandlerFunc {
|
|||
session := r.Context().Value("session").(*sessions.Session)
|
||||
loggedIn := session.Values["user_id"] != nil
|
||||
userID, _ := session.Values["user_id"].(int)
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
|
||||
publicBoards, err := models.GetAllBoards(app.DB, false)
|
||||
if err != nil {
|
||||
|
@ -50,7 +51,7 @@ func BoardsHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - Boards",
|
||||
Navbar: "boards",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
|
@ -19,7 +19,7 @@ func HomeHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - Home",
|
||||
Navbar: "home",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value == "",
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: filepath.Join(app.Config.ThreadrDir, "static"),
|
||||
CurrentURL: r.URL.String(),
|
||||
|
|
|
@ -10,6 +10,7 @@ func NewsHandler(app *App) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value("session").(*sessions.Session)
|
||||
loggedIn := session.Values["user_id"] != nil
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
newsItems := []string{
|
||||
"2020-02-21 Whole Website updated: Homepage, News, Boards, About, Log In, Userhome, Log Out",
|
||||
"2020-01-06 First Steps done",
|
||||
|
@ -22,7 +23,7 @@ func NewsHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - News",
|
||||
Navbar: "news",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
func SignupHandler(app *App) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value("session").(*sessions.Session)
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
if r.Method == http.MethodPost {
|
||||
username := r.FormValue("username")
|
||||
password := r.FormValue("password")
|
||||
|
@ -24,7 +25,7 @@ func SignupHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - Sign Up",
|
||||
Navbar: "signup",
|
||||
LoggedIn: false,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
@ -49,7 +50,7 @@ func SignupHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - Sign Up",
|
||||
Navbar: "signup",
|
||||
LoggedIn: session.Values["user_id"] != nil,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
|
@ -13,6 +13,7 @@ func ThreadHandler(app *App) http.HandlerFunc {
|
|||
session := r.Context().Value("session").(*sessions.Session)
|
||||
loggedIn := session.Values["user_id"] != nil
|
||||
userID, _ := session.Values["user_id"].(int)
|
||||
cookie, _ := r.Cookie("threadr_cookie_banner")
|
||||
|
||||
threadIDStr := r.URL.Query().Get("id")
|
||||
threadID, err := strconv.Atoi(threadIDStr)
|
||||
|
@ -123,7 +124,7 @@ func ThreadHandler(app *App) http.HandlerFunc {
|
|||
Title: "ThreadR - " + thread.Title,
|
||||
Navbar: "boards",
|
||||
LoggedIn: loggedIn,
|
||||
ShowCookieBanner: true,
|
||||
ShowCookieBanner: cookie == nil || cookie.Value != "accepted",
|
||||
BasePath: app.Config.ThreadrDir,
|
||||
StaticPath: app.Config.ThreadrDir + "/static",
|
||||
CurrentURL: r.URL.Path,
|
||||
|
|
Loading…
Reference in New Issue