pull/168/head
Gordon 3 years ago
parent 0e9e02de0b
commit 72ed38156a

@ -5,7 +5,6 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/utils"
"bytes"
"encoding/gob"
@ -258,16 +257,16 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool {
status := http.StatusUnauthorized
query := r.URL.Query()
if len(query["token"]) != 0 && len(query["sendID"]) != 0 && len(query["platformID"]) != 0 {
if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
e := err.(*constant.ErrInfo)
log.ErrorByKv("Token verify failed", "", "query", query)
w.Header().Set("Sec-Websocket-Version", "13")
http.Error(w, e.ErrMsg, int(e.ErrCode))
return false
} else {
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
return true
}
//if ok, err := token_verify.VerifyToken(query["token"][0], query["sendID"][0]); !ok {
// e := err.(*constant.ErrInfo)
// log.ErrorByKv("Token verify failed", "", "query", query)
// w.Header().Set("Sec-Websocket-Version", "13")
// http.Error(w, e.ErrMsg, int(e.ErrCode))
// return false
//} else {
log.InfoByKv("Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0])
return true
//}
} else {
log.ErrorByKv("Args err", "", "query", query)
w.Header().Set("Sec-Websocket-Version", "13")

Loading…
Cancel
Save