reid пре 2 година
родитељ
комит
55155a8c3f
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      auth/auth.go

+ 3 - 3
auth/auth.go

@@ -51,13 +51,13 @@ func WsIsAuthenticated(conn *websocket.Conn, token string) bool {
 	}
 }
 
-// quick check if websocket is authed at all for unauth broadcast (not for actual auth)
+// quick check if websocket is authed at all for unauth broadcast (not for auth on its own)
 func WsAuthCheck(conn *websocket.Conn) bool {
 	AuthenticatedClients.RLock()
 	defer AuthenticatedClients.RUnlock()
 	for tokenID, con := range AuthenticatedClients.Conns {
 		if con == conn {
-			config.Logger.Info("%s is in auth map",tokenID)
+			config.Logger.Info(fmt.Sprintf("%s is in auth map",tokenID))
 			return true
 		}
 	}
@@ -142,7 +142,7 @@ func CheckToken(token map[string]string, conn *websocket.Conn, r *http.Request,
 		// hashed := sha512.Sum512([]byte(token["token"]))
 		// hash := hex.EncodeToString(hashed[:])
 		// you in auth map?
-		if WsIsAuthenticated(conn, token["id"]) {
+		if WsAuthCheck(conn, token["id"]) {
 			if ip == res["ip"] && userAgent == res["user_agent"] {
 				config.Logger.Info("Token authenticated")
 				return true