Skip to content

Commit

Permalink
Check subscription (#196)
Browse files Browse the repository at this point in the history
* Access reports only if there is a subscription

* custom error message when not enterprise

nethesis/ns8-nethvoice#207
  • Loading branch information
Stell0 authored May 23, 2024
1 parent 9086277 commit b967fd1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
"github.com/nethesis/nethvoice-report/api/methods"
"github.com/nethesis/nethvoice-report/api/models"
"github.com/nethesis/nethvoice-report/api/utils"

"os"
)

type login struct {
Expand Down Expand Up @@ -75,6 +77,14 @@ func InitJWT() *jwt.GinJWTMiddleware {
username := loginVals.Username
password := loginVals.Password

// check subscription
subscription_systemid := os.Getenv("SUBSCRIPTION_SYSTEMID")
subscription_secret := os.Getenv("SUBSCRIPTION_SECRET")
if subscription_systemid == "" || subscription_secret == "" {
utils.LogError(errors.New("Error! Reports available only on Enterprise version."))
return nil, errors.New("Reports available only on Enterprise version")
}

// check if login is with API key or User and Password
if username == "X" {
// try API key authentication
Expand Down

0 comments on commit b967fd1

Please sign in to comment.