trim whitespaces so sharecode does match
This commit is contained in:
7
main.go
7
main.go
@@ -31,6 +31,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
@@ -495,8 +496,8 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
id := mux.Vars(r)["id"]
|
||||
authCode := r.Form.Get("authcode")
|
||||
shareCode := r.Form.Get("sharecode")
|
||||
authCode := strings.TrimSpace(r.Form.Get("authcode"))
|
||||
shareCode := strings.TrimSpace(r.Form.Get("sharecode"))
|
||||
|
||||
if id == "" || authCode == "" || !utils.AuthCodeRegEx.MatchString(authCode) {
|
||||
log.Infof("[PPT] invalid arguments: %+v, %+v, %+v", id, authCode, shareCode)
|
||||
@@ -528,7 +529,7 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
case utils.SharecodeNoMatchError:
|
||||
log.Infof("[PPT] shareCode provided for player %s is invalid: %v", id, e)
|
||||
log.Infof("[PPT] shareCode provided for player %s (%s) is invalid: %v", id, shareCode, e)
|
||||
w.WriteHeader(http.StatusPreconditionFailed)
|
||||
return
|
||||
default:
|
||||
|
Reference in New Issue
Block a user