feat(backend): changed licence verification url

This commit is contained in:
Alexander 2024-04-25 13:56:29 +02:00
parent 91fbaeeef6
commit d1c4ba496d

View file

@ -1,39 +1,36 @@
package license
import (
"log"
"net/http"
"bytes"
"encoding/json"
"io/ioutil"
"bytes"
"log"
"net/http"
"openreplay/backend/pkg/env"
)
type request struct {
MID string `json:"mid"`
MID string `json:"mid"`
License string `json:"license"`
}
type response struct {
Data struct {
IsValid bool `json:"valid"`
IsValid bool `json:"valid"`
ExpirationTimestamp int64 `json:"expiration"`
} `json:"data"`
}
func CheckLicense() {
license := env.String("LICENSE_KEY")
requestBody, err := json.Marshal(request{ License: license })
requestBody, err := json.Marshal(request{License: license})
if err != nil {
log.Fatal("Can not form a license check request.")
}
resp, err := http.Post("https://api.openreplay.com/os/license", "application/json", bytes.NewReader(requestBody))
resp, err := http.Post("https://api.openreplay.com/os/license/validate", "application/json", bytes.NewReader(requestBody))
if err != nil {
log.Fatalf("Error while checking license. %v", err)
}
@ -57,5 +54,4 @@ func CheckLicense() {
log.Fatal("License is not valid.")
}
}
}