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