-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpages.go
More file actions
88 lines (79 loc) · 2.07 KB
/
Copy pathpages.go
File metadata and controls
88 lines (79 loc) · 2.07 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"log"
"net/http"
"github.com/WiiLink24/AccountManager/middleware"
"github.com/gin-gonic/gin"
)
func HomePage(c *gin.Context) {
username, _ := c.Get("username")
email, _ := c.Get("email")
wiis, _ := c.Get("wiis")
exists := len(wiis.([]middleware.Wii)) != 0
dominos := map[string]bool{}
for _, wii := range wiis.([]middleware.Wii) {
dominos[wii.WiiNumber] = wii.DominosLinked
}
if exists {
log.Printf("User with username %s is linked!!!", username)
if pfp, ok := c.Get("picture"); ok {
c.HTML(http.StatusOK, "linked.html", gin.H{
"username": username,
"email": email,
"pfp": pfp,
"dominos": dominos,
"wiis": wiis.([]middleware.Wii),
})
} else {
c.HTML(http.StatusOK, "linked.html", gin.H{
"username": username,
"email": email,
"dominos": dominos,
"wiis": wiis.([]middleware.Wii),
})
}
} else {
log.Printf("User with username %s is not linked", username)
if pfp, ok := c.Get("picture"); ok {
c.HTML(http.StatusOK, "not_linked.html", gin.H{
"username": username,
"pfp": pfp,
"email": email,
})
} else {
c.HTML(http.StatusOK, "not_linked.html", gin.H{
"username": username,
"email": email,
})
}
}
}
func NotLinkedPage(c *gin.Context) {
email, _ := c.Get("email")
log.Printf("User with email %s is not linked", email)
c.HTML(http.StatusOK, "not_linked.html", gin.H{
"email": email,
})
}
func PrivacyPage(c *gin.Context) {
username, _ := c.Get("username")
email, _ := c.Get("email")
public_profile, _ := c.Get("public_profile")
wiis, _ := c.Get("wiis")
if pfp, ok := c.Get("picture"); ok {
c.HTML(http.StatusOK, "privacy-settings.html", gin.H{
"username": username,
"email": email,
"public_profile": public_profile,
"wiis": wiis.([]middleware.Wii),
"pfp": pfp,
})
} else {
c.HTML(http.StatusOK, "privacy-settings.html", gin.H{
"username": username,
"email": email,
"public_profile": public_profile,
"wiis": wiis.([]middleware.Wii),
})
}
}