dashboard-v2/app/http/middleware/verifywhitelabel.go
biast12 c5da11792c Removed FORCED_WHITELABEL
This removes the env var FORCED_WHITELABEL, this was only used for testing in the early days of whitelabel and is unused now
2025-02-05 21:56:48 +01:00

36 lines
803 B
Go

package middleware
import (
"fmt"
"github.com/TicketsBot/GoPanel/config"
"github.com/TicketsBot/GoPanel/rpc"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/common/premium"
"github.com/gin-gonic/gin"
)
func VerifyWhitelabel(isApi bool) func(ctx *gin.Context) {
return func(ctx *gin.Context) {
userId := ctx.Keys["userid"].(uint64)
tier, err := rpc.PremiumClient.GetTierByUser(ctx, userId, false)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
if tier < premium.Whitelabel {
if isApi {
ctx.AbortWithStatusJSON(402, gin.H{
"success": false,
"error": "You must have the whitelabel premium tier",
})
} else {
ctx.Redirect(302, fmt.Sprintf("%s/premium", config.Conf.Server.MainSite))
ctx.Abort()
}
return
}
}
}