add app limit

This commit is contained in:
stremovsky
2019-12-14 18:43:43 +02:00
parent ed0a2b9cef
commit 0e23a2030e
2 changed files with 14 additions and 0 deletions

View File

@@ -630,6 +630,16 @@ func (dbobj dbcon) getAllTables() ([]string, error) {
return knownApps, nil
}
func (dbobj dbcon) validateNewApp(appName string) bool {
if contains(knownApps, appName) == true {
return true
}
if len(knownApps) >= 10 {
return false
}
return true
}
func (dbobj dbcon) indexNewApp(appName string) {
if contains(knownApps, appName) == false {
// it is a new app, create an index

View File

@@ -24,6 +24,10 @@ func (e mainEnv) userappNew(w http.ResponseWriter, r *http.Request, ps httproute
returnError(w, r, "bad appname", 405, nil, event)
return
}
if e.db.validateNewApp("app_"+appName) == false {
returnError(w, r, "db limitation", 405, nil, event)
return
}
data, err := getJSONPostData(r)
if err != nil {