Skip to content

Commit 7fa5e97

Browse files
authored
Merge branch 'master' into disable
2 parents c22e7a5 + a5bbae0 commit 7fa5e97

File tree

9 files changed

+125
-199
lines changed

9 files changed

+125
-199
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
persistence.json
22
authdb.json
33
.idea/workspace.xml
4+
210-queue-system

.idea/workspace.xml

Lines changed: 77 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,11 @@ func handleJoinReq(c *gin.Context) {
5757
}
5858
if HasJoinedQueue(CSid) {
5959
hpv := HomePageValues{Error: "You have already joined the queue! Click above to see your status."}
60-
c.SetCookie("queue-csid", CSid, 0, "",
61-
"", false, false)
6260
c.HTML(http.StatusOK, "index.tmpl.html", hpv)
6361
return
6462
}
65-
c.SetCookie("queue-csid", CSid, 0, "",
66-
"cpsc210queue.ugrad.cs.ubc.ca", true, false)
67-
c.SetCookie("queue-secret", GenerateSecretForCSid(CSid), 0, "",
68-
"cpsc210queue.ugrad.cs.ubc.ca", true, false)
63+
c.SetCookie("queue-csid", CSid, 0, "", "", true, false)
64+
c.SetCookie("queue-secret", GenerateSecretForCSid(CSid), 0, "", "", true, false)
6965
aheadOfMe, waitTime := JoinQueue(name, CSid, taskInfo)
7066
if waitTime != -1 {
7167
c.HTML(http.StatusOK, "status.tmpl.html", nil)
@@ -146,7 +142,8 @@ func handleCloseQueue(c *gin.Context) {
146142

147143
func getCSIDFromCookie(c *gin.Context) string {
148144
CSid, err := c.Cookie("queue-csid")
149-
if err != nil || CSid == "" || !IsValidCSid(CSid) {
145+
secret, err1 := c.Cookie("queue-secret")
146+
if err != nil || err1 != nil || CSid == "" || !IsValidCSid(CSid) || !CheckSecretForCSid(secret, CSid) {
150147
c.AbortWithStatus(http.StatusBadRequest)
151148
return ""
152149
}

templates/header.tmpl.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<head>
22
<title>CPSC 210 Lab Queue</title>
3-
<script src="/static/js/jquery-3.3.1.min.js"></script>
4-
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
53
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css"/>
64
<link rel="stylesheet" type="text/css" href="/static/css/main.css"/>
75
<link rel="stylesheet" href="/static/css/all.css"/>

templates/index.tmpl.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ <h5 class="card-header"><i class="fas fa-question-circle"></i> What is this tool
7272
</div>
7373
{{template "footer.tmpl.html"}}
7474
</div>
75-
7675
<script type="text/javascript">
7776
function getQueueStatus() {
7877
let xhr = new XMLHttpRequest();
@@ -103,6 +102,6 @@ <h5 class="card-header"><i class="fas fa-question-circle"></i> What is this tool
103102
getQueueStatus();
104103
}, 5000);
105104
</script>
106-
105+
{{template "scripts.tmpl.html"}}
107106
</body>
108107
</html>

templates/rejected.tmpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ <h5 class="card-header card-title bg-danger text-white"><i class="fas fa-times-c
3030
</div>
3131
{{template "footer.tmpl.html"}}
3232
</div>
33-
33+
{{template "scripts.tmpl.html"}}
3434
</body>
3535
</html>

templates/scripts.tmpl.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<script src="/static/js/jquery-3.3.1.min.js"></script>
2+
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>

templates/status.tmpl.html

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,42 @@
22
{{template "header.tmpl.html"}}
33
<body>
44
{{template "nav.tmpl.html"}}
5+
<div class="container">
6+
<div class="row">
7+
<div class="col-sm">
8+
<br/>
9+
<div class="card border-warning" id="notwaiting" hidden="hidden">
10+
<h5 class="card-header bg-warning"><i class="fas fa-exclamation-triangle"></i> You're not in
11+
the queue.</h5>
12+
<p class="card-body">Go to the <a href="/">homepage</a> to join the queue.</p>
13+
</div>
14+
<div class="card border-info" id="currentstatus" hidden="hidden">
15+
<h5 class="card-header bg-info text-white"><i class="fas fa-smile"></i> Cool, you're in the queue!</h5>
16+
<div class="card-body">
17+
<p>Hey <b><span id="csid"></span></b>, thanks for waiting.
18+
There are currently <b>
19+
<mark id="position"></mark>
20+
</b> students
21+
before you.
22+
Your estimated waiting time is <b>
23+
<mark id="waittime"></mark>
24+
</b> minutes.
25+
</p>
26+
<p><a href="/leaveearly">
27+
<button type="button" class="btn btn-danger"><i class="fas fa-door-open"></i> Exit the queue
28+
now
29+
</button>
30+
</a></p>
31+
<p class="small text-muted">This view refreshes automatically every 5 seconds, no need to
32+
reload the page! Do not close this browser window to keep track of your position.</p>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
{{template "footer.tmpl.html"}}
38+
</div>
539

40+
{{template "scripts.tmpl.html"}}
641
<script type="text/javascript">
742

843
function deleteCookie(name) {
@@ -29,6 +64,9 @@
2964
var username = getCookie("queue-csid");
3065
if (username !== "") {
3166
fillPosition();
67+
} else {
68+
document.getElementById("notwaiting").hidden = false;
69+
document.getElementById("currentstatus").hidden = true;
3270
}
3371
}
3472

@@ -64,40 +102,5 @@
64102
}, 5000);
65103
</script>
66104

67-
<div class="container">
68-
<div class="row">
69-
<div class="col-sm">
70-
<br/>
71-
<div class="card border-warning" id="notwaiting">
72-
<h5 class="card-header bg-warning"><i class="fas fa-exclamation-triangle"></i> You're not in
73-
the queue.</h5>
74-
<p class="card-body">Go to the <a href="/">homepage</a> to join the queue.</p>
75-
</div>
76-
<div class="card border-info" id="currentstatus" hidden="hidden">
77-
<h5 class="card-header bg-info text-white"><i class="fas fa-smile"></i> Cool, you're in the queue!</h5>
78-
<div class="card-body">
79-
<p>Hey <b><span id="csid"></span></b>, thanks for waiting.
80-
There are currently <b>
81-
<mark id="position"></mark>
82-
</b> students
83-
before you.
84-
Your estimated waiting time is <b>
85-
<mark id="waittime"></mark>
86-
</b> minutes.
87-
</p>
88-
<p><a href="/leaveearly">
89-
<button type="button" class="btn btn-danger"><i class="fas fa-door-open"></i> Exit the queue
90-
now
91-
</button>
92-
</a></p>
93-
<p class="small text-muted">This view refreshes automatically every 5 seconds, no need to
94-
reload the page! Do not close this browser window to keep track of your position.</p>
95-
</div>
96-
</div>
97-
</div>
98-
</div>
99-
{{template "footer.tmpl.html"}}
100-
</div>
101-
102105
</body>
103106
</html>

templates/tastatus.tmpl.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ <h5><i class="fas fa-user-md"></i> TA admin panel</h5>
5252
</div>
5353
{{template "footer.tmpl.html"}}
5454
</div>
55-
5655
<script type="text/javascript">
5756

5857
function getQueueStatus() {
@@ -118,6 +117,6 @@ <h5><i class="fas fa-user-md"></i> TA admin panel</h5>
118117
getQueueStatus();
119118
}, 5000);
120119
</script>
121-
120+
{{template "scripts.tmpl.html"}}
122121
</body>
123122
</html>

0 commit comments

Comments
 (0)