-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.go
43 lines (36 loc) · 844 Bytes
/
home.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"net/http"
"strings"
"time"
)
// Handler for / renders the home.html page
func Home(w http.ResponseWriter, r *http.Request) {
sig := getSignatureFromCookies(r)
errmsg := r.FormValue("errmsg")
message := ""
switch errmsg {
case "TokenNotFound":
message = "There was a problem authenticating you with Patreon."
case "UserNotFound", "TierNotFound":
message = ErrMsg
case "logout":
domain := "mtgban.com"
if strings.Contains(getBaseURL(r), "localhost") {
domain = "localhost"
}
// Invalidate the current cookie
cookie := http.Cookie{
Name: "MTGBAN",
Domain: domain,
Path: "/",
Expires: time.Now(),
}
http.SetCookie(w, &cookie)
// Delete signature
sig = ""
}
pageVars := genPageNav("Home", sig)
pageVars.ErrorMessage = message
render(w, "home.html", pageVars)
}