1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-06 22:15:25 +02:00

Subscription checks

This commit is contained in:
Harvey Kandola 2018-10-29 16:53:54 +00:00
parent 6e4c5194e2
commit e116d3b000
20 changed files with 211 additions and 76 deletions

View file

@ -51,7 +51,7 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
method := "user.Add"
ctx := domain.GetRequestContext(r)
if !h.Runtime.Product.License.IsValid() {
if !h.Runtime.Product.License.IsValid(ctx.OrgID) {
response.WriteBadLicense(w)
}

View file

@ -14,6 +14,7 @@ package user
import (
"database/sql"
"fmt"
"github.com/documize/community/core/env"
"strconv"
"strings"
"time"
@ -312,17 +313,11 @@ func (s Store) ForgotUserPassword(ctx domain.RequestContext, email, token string
}
// CountActiveUsers returns the number of active users in the system.
func (s Store) CountActiveUsers() (c int) {
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE c_active=true)")
err := row.Scan(&c)
if err == sql.ErrNoRows {
return 0
}
func (s Store) CountActiveUsers() (c []env.LicenseUserAcount) {
err := s.Runtime.Db.Select(&c, "SELECT c_orgid AS orgid, COUNT(*) AS users FROM dmz_user_account WHERE c_active=true GROUP BY c_orgid ORDER BY c_orgid")
if err != nil && err != sql.ErrNoRows {
s.Runtime.Log.Error("CountActiveUsers", err)
return 0
}
return