diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..3026b2e --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +VOTE_HOST=http://localhost:8080 +VOTE_STATE=1000000 +VOTE_OIDC_ID=develop +VOTE_JWT_SECRET=ahahaisdfjioThisShouldBeRandom +VOTE_OIDC_SECRET=no peeking (on wiki) +DEV_DISABLE_ACTIVE_FILTERS=true +DEV_FORCE_IS_EVALS=true +VOTE_CONDITIONAL_URL=https://conditional.csh.rit.edu/gatekeep +VOTE_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +VOTE_MONGODB_URI=mongodb://vote:c1f66aac6b4fafbef3c659371b8a50ed@mongodb/vote?authSource=admin +VOTE_ANNOUNCEMENTS_CHANNEL_ID= +VOTE_SLACK_APP_TOKEN= +VOTE_SLACK_BOT_TOKEN= diff --git a/.gitignore b/.gitignore index 20e2001..212e1b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.env* +.env vote .idea/ -.vscode/ \ No newline at end of file +.vscode/ + diff --git a/README.md b/README.md index 306981a..a692756 100644 --- a/README.md +++ b/README.md @@ -11,23 +11,7 @@ Implementation ## Configuration -If you're using the compose file, you'll need to ask an RTP for the vote-dev OIDC secret, and set it as `VOTE_OIDC_SECRET` in your environment - -If you're not using the compose file, you'll need more of these - -``` -VOTE_HOST=http://localhost:8080 -VOTE_JWT_SECRET= -VOTE_MONGODB_URI= -VOTE_OIDC_ID= -VOTE_OIDC_SECRET= -VOTE_STATE= -VOTE_TOKEN= -VOTE_CONDITIONAL_URL=https://conditional.csh.rit.edu/gatekeep/ -VOTE_ANNOUNCEMENTS_CHANNEL_ID= -VOTE_SLACK_APP_TOKEN= -VOTE_SLACK_BOT_TOKEN= -``` +Copy `.env.example` to `.env` and fill out the info ### Dev Overrides `DEV_DISABLE_ACTIVE_FILTERS="true"` will disable the requirements that you be active to vote diff --git a/api.go b/api.go index e7cc385..1a11815 100644 --- a/api.go +++ b/api.go @@ -195,6 +195,10 @@ func CreatePoll(c *gin.Context) { } poll.AllowedUsers = GetEligibleVoters() for user := range strings.SplitSeq(c.PostForm("waivedUsers"), ",") { + if len(user) == 0 { // When it's empty (and probably in other cases) the split can return an empty string, which changes the total + continue + } + poll.AllowedUsers = append(poll.AllowedUsers, strings.TrimSpace(user)) } } diff --git a/docker-compose.yaml b/docker-compose.yaml index 4902a92..0d279f3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,15 +13,9 @@ services: container_name: vote depends_on: - mongodb - environment: - VOTE_HOST: 'http://localhost:8080' - VOTE_JWT_SECRET: 4874c601dda90a01c7543c571be08680 - VOTE_MONGODB_URI: "mongodb://vote:c1f66aac6b4fafbef3c659371b8a50ed@mongodb/vote?authSource=admin" - VOTE_OIDC_ID: vote-dev - VOTE_OIDC_SECRET: "${VOTE_OIDC_SECRET}" - VOTE_STATE: 27a28540e47ec786b7bdad03f83171b3 - DEV_DISABLE_ACTIVE_FILTERS: "${DEV_DISABLE_ACTIVE_FILTERS}" - DEV_FORCE_IS_EVALS: "${DEV_FORCE_IS_EVALS}" + env_file: + - path: .env + required: false ports: - "127.0.0.1:8080:8080"