mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
dev day #69
This commit is contained in:
@@ -357,14 +357,14 @@ func (pc *PollController) DeletePoll(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Poll deleted successfully"})
|
||||
}
|
||||
|
||||
// Vote handles vote submission
|
||||
func (pc *PollController) Vote(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
var input struct {
|
||||
OptionIDs []uint `json:"option_ids" binding:"required,min=1"`
|
||||
SessionToken string `json:"session_token"`
|
||||
VoterName string `json:"voter_name"`
|
||||
VoterEmail string `json:"voter_email"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
@@ -412,6 +412,12 @@ func (pc *PollController) Vote(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// If not authenticated, don't persist personal info even if provided
|
||||
if !hasUser {
|
||||
input.VoterName = ""
|
||||
input.VoterEmail = ""
|
||||
}
|
||||
|
||||
// Check if already voted
|
||||
ipHash := pc.hashIP(c.ClientIP())
|
||||
sessionToken := input.SessionToken
|
||||
@@ -462,6 +468,8 @@ func (pc *PollController) Vote(c *gin.Context) {
|
||||
IPHash: ipHash,
|
||||
UserAgent: userAgent,
|
||||
SessionToken: sessionToken,
|
||||
VoterName: input.VoterName,
|
||||
VoterEmail: input.VoterEmail,
|
||||
}
|
||||
|
||||
if hasUser {
|
||||
|
||||
Reference in New Issue
Block a user