2021-02-07 19:56:53 +00:00

45 lines
1003 B
Go

package root
import (
"fmt"
"github.com/TicketsBot/GoPanel/config"
"github.com/TicketsBot/GoPanel/rpc"
"github.com/TicketsBot/common/premium"
"github.com/gin-gonic/contrib/sessions"
"github.com/gin-gonic/gin"
)
func WhitelabelHandler(ctx *gin.Context) {
store := sessions.Default(ctx)
if store == nil {
return
}
defer store.Save()
userId := store.Get("userid").(uint64)
premiumTier := rpc.PremiumClient.GetTierByUser(userId, false)
if premiumTier < premium.Whitelabel {
var isForced bool
for _, forced := range config.Conf.ForceWhitelabel {
if forced == userId {
isForced = true
break
}
}
if !isForced {
ctx.Redirect(302, fmt.Sprintf("%s/premium", config.Conf.Server.MainSite))
return
}
}
ctx.HTML(200, "main/whitelabel", gin.H{
"name": store.Get("name").(string),
"baseurl": config.Conf.Server.BaseUrl,
"avatar": store.Get("avatar").(string),
"referralShow": config.Conf.Referral.Show,
"referralLink": config.Conf.Referral.Link,
})
}