Skip to content

Commit 458dab2

Browse files
authored
Merge pull request #99 from ComputerScienceHouse/eboard-gatekeep
Allow all of eboard to enable gatekeep
2 parents ac72ac1 + b976d16 commit 458dab2

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ VOTE_SLACK_BOT_TOKEN=
3131

3232
### Dev Overrides
3333
`DEV_DISABLE_ACTIVE_FILTERS="true"` will disable the requirements that you be active to vote
34+
`DEV_FORCE_IS_EBOARD="true"` will force vote to treat all users as E-Board members
3435
`DEV_FORCE_IS_EVALS="true"` will force vote to treat all users as the Evals director
3536

3637
## Linting
@@ -56,7 +57,7 @@ go vet *.go
5657
- [ ] Don't let the user fuck it up
5758
- [ ] Show E-Board polls with a higher priority
5859
- [x] Move Hide Vote to create instead of after you vote :skull:
59-
- [ ] Display the reason why a user is on the results page of a running poll
60+
- [X] Display the reason why a user is on the results page of a running poll
6061
- [ ] Display minimum time left that a poll is open
6162
- [ ] Move routes to their own functions
62-
- [ ] Change HTTP resposne codes to be `http.something` instead of just a number
63+
- [X] Change HTTP resposne codes to be `http.something` instead of just a number

main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var VOTE_HOST = os.Getenv("VOTE_HOST")
3131

3232
// Dev mode flags
3333
var DEV_DISABLE_ACTIVE_FILTERS bool = os.Getenv("DEV_DISABLE_ACTIVE_FILTERS") == "true"
34+
var DEV_FORCE_IS_EBOARD bool = os.Getenv("DEV_FORCE_IS_EBOARD") == "true"
3435
var DEV_FORCE_IS_EVALS bool = os.Getenv("DEV_FORCE_IS_EVALS") == "true"
3536

3637
func inc(x int) string {
@@ -86,7 +87,9 @@ func main() {
8687
if DEV_DISABLE_ACTIVE_FILTERS {
8788
logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev disable active filters is set!")
8889
}
89-
90+
if DEV_FORCE_IS_EBOARD {
91+
logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev force eboard is set!")
92+
}
9093
if DEV_FORCE_IS_EVALS {
9194
logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev force evals is set!")
9295
}
@@ -164,7 +167,7 @@ func main() {
164167
c.HTML(http.StatusOK, "create.tmpl", gin.H{
165168
"Username": claims.UserInfo.Username,
166169
"FullName": claims.UserInfo.FullName,
167-
"IsEvals": isEvals(claims.UserInfo),
170+
"IsEboard": isEboard(claims.UserInfo),
168171
})
169172
}))
170173

@@ -225,7 +228,7 @@ func main() {
225228
poll.Options = []string{"Pass", "Fail", "Abstain"}
226229
}
227230
if poll.Gatekeep {
228-
if !isEvals(claims.UserInfo) {
231+
if !isEboard(claims.UserInfo) {
229232
c.HTML(http.StatusForbidden, "unauthorized.tmpl", gin.H{
230233
"Username": claims.UserInfo.Username,
231234
"FullName": claims.UserInfo.FullName,
@@ -554,6 +557,11 @@ func main() {
554557
r.Run()
555558
}
556559

560+
// isEboard determines if the current user is on eboard, allowing for a dev mode override
561+
func isEboard(user cshAuth.CSHUserInfo) bool {
562+
return DEV_FORCE_IS_EBOARD || slices.Contains(user.Groups, "eboard")
563+
}
564+
557565
// isEvals determines if the current user is evals, allowing for a dev mode override
558566
func isEvals(user cshAuth.CSHUserInfo) bool {
559567
return DEV_FORCE_IS_EVALS || slices.Contains(user.Groups, "eboard-evaluations")

templates/create.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
>
7474
<span>Hide Results Until Vote is Complete</span>
7575
</div>
76-
{{ if .IsEvals }}
76+
{{ if .IsEboard }}
7777
<div class="form-group">
7878
<input
7979
type="checkbox"

0 commit comments

Comments
 (0)