mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
implemented edition license checks
This commit is contained in:
parent
edccb39019
commit
a4e3264e0c
19 changed files with 146 additions and 19 deletions
|
@ -109,25 +109,13 @@ func GetLicense(w http.ResponseWriter, r *http.Request) {
|
|||
fmt.Println(err)
|
||||
}
|
||||
|
||||
output, err := xml.MarshalIndent(x, " ", " ")
|
||||
output, err := xml.Marshal(x)
|
||||
if err != nil {
|
||||
fmt.Printf("error: %v\n", err)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(output)
|
||||
|
||||
// // marshal as JSON
|
||||
// var y map[string]interface{}
|
||||
// json.Unmarshal([]byte(config), &y)
|
||||
|
||||
// json, err := json.Marshal(y)
|
||||
// if err != nil {
|
||||
// writeJSONMarshalError(w, method, "EDITION-LICENSE", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// util.WriteSuccessBytes(w, json)
|
||||
}
|
||||
|
||||
// SaveLicense persists product license
|
||||
|
|
|
@ -41,6 +41,11 @@ func writeTransactionError(w http.ResponseWriter, method string, err error) {
|
|||
log.Error(fmt.Sprintf("Unable to get database transaction for method %s", method), err)
|
||||
}
|
||||
|
||||
// IsInvalidLicense returns true if license is invalid
|
||||
func IsInvalidLicense() bool {
|
||||
return Product.License.Valid == false
|
||||
}
|
||||
|
||||
/*
|
||||
func WriteAddRecordError(w http.ResponseWriter, method string, err error) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
|
|
@ -32,6 +32,11 @@ import (
|
|||
|
||||
// AddFolder creates a new folder.
|
||||
func AddFolder(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "AddFolder"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -263,6 +268,11 @@ func UpdateFolder(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// RemoveFolder moves documents to another folder before deleting it
|
||||
func RemoveFolder(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "RemoveFolder"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
|
|||
data.Message = org.Message
|
||||
data.AllowAnonymousAccess = org.AllowAnonymousAccess
|
||||
data.Version = Product.Version
|
||||
data.Edition = Product.License.Edition
|
||||
data.Valid = Product.License.Valid
|
||||
|
||||
json, err := json.Marshal(data)
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@ import (
|
|||
|
||||
// AddDocumentPage inserts new section into document.
|
||||
func AddDocumentPage(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "AddDocumentPage"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -286,6 +291,11 @@ func GetDocumentPagesBatch(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// DeleteDocumentPage deletes a page.
|
||||
func DeleteDocumentPage(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "DeleteDocumentPage"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -354,6 +364,11 @@ func DeleteDocumentPage(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// DeleteDocumentPages batch deletes pages.
|
||||
func DeleteDocumentPages(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "DeleteDocumentPages"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -433,6 +448,11 @@ func DeleteDocumentPages(w http.ResponseWriter, r *http.Request) {
|
|||
// that this is a new revision. If the page is the first in a document
|
||||
// then the corresponding document title will also be changed.
|
||||
func UpdateDocumentPage(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "UpdateDocumentPage"
|
||||
p := request.GetPersister(r)
|
||||
params := mux.Vars(r)
|
||||
|
@ -540,6 +560,11 @@ func UpdateDocumentPage(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// ChangeDocumentPageSequence will swap page sequence for a given number of pages.
|
||||
func ChangeDocumentPageSequence(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "ChangeDocumentPageSequence"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -598,6 +623,11 @@ func ChangeDocumentPageSequence(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// ChangeDocumentPageLevel handles page indent/outdent changes.
|
||||
func ChangeDocumentPageLevel(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "ChangeDocumentPageLevel"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -740,6 +770,11 @@ func GetPageMoveCopyTargets(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// GetDocumentRevisions returns all changes for a document.
|
||||
func GetDocumentRevisions(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "GetDocumentPageRevisions"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -770,6 +805,11 @@ func GetDocumentRevisions(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// GetDocumentPageRevisions returns all changes for a given page.
|
||||
func GetDocumentPageRevisions(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "GetDocumentPageRevisions"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
@ -807,6 +847,11 @@ func GetDocumentPageRevisions(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// GetDocumentPageDiff returns HTML diff between two revisions of a given page.
|
||||
func GetDocumentPageDiff(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "GetDocumentPageDiff"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ import (
|
|||
|
||||
// AddPin saves pinned item.
|
||||
func AddPin(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "AddPin"
|
||||
p := request.GetPersister(r)
|
||||
params := mux.Vars(r)
|
||||
|
@ -131,6 +136,11 @@ func GetUserPins(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// DeleteUserPin removes saved user pin.
|
||||
func DeleteUserPin(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "DeleteUserPin"
|
||||
p := request.GetPersister(r)
|
||||
params := mux.Vars(r)
|
||||
|
@ -175,6 +185,11 @@ func DeleteUserPin(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// UpdatePinSequence records order of pinned items.
|
||||
func UpdatePinSequence(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "UpdatePinSequence"
|
||||
p := request.GetPersister(r)
|
||||
params := mux.Vars(r)
|
||||
|
|
|
@ -185,6 +185,11 @@ func RefreshSections(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// AddBlock inserts new reusable content block into database.
|
||||
func AddBlock(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "AddBlock"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ var Product core.ProdInfo
|
|||
|
||||
func init() {
|
||||
Product.Major = "0"
|
||||
Product.Minor = "42"
|
||||
Product.Minor = "43"
|
||||
Product.Patch = "0"
|
||||
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
|
||||
Product.Edition = "Community"
|
||||
|
|
|
@ -36,6 +36,11 @@ import (
|
|||
|
||||
// SaveAsTemplate saves existing document as a template.
|
||||
func SaveAsTemplate(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "SaveAsTemplate"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@ import (
|
|||
|
||||
// AddUser is the endpoint that enables an administrator to add a new user for their orgaisation.
|
||||
func AddUser(w http.ResponseWriter, r *http.Request) {
|
||||
if IsInvalidLicense() {
|
||||
util.WriteBadLicense(w)
|
||||
return
|
||||
}
|
||||
|
||||
method := "AddUser"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue