add admins config field

This commit is contained in:
Dot-Rar 2019-12-16 18:30:02 +00:00
parent f85b043c27
commit 85f2730fb0
11 changed files with 13 additions and 9 deletions

View File

@ -44,7 +44,7 @@ func BlacklistHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -44,7 +44,7 @@ func BlacklistRemoveHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -53,7 +53,7 @@ func LogsHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -46,7 +46,7 @@ func SendMessage(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -48,7 +48,7 @@ func SettingsHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -45,7 +45,7 @@ func TicketListHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -50,7 +50,7 @@ func TicketViewHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -47,7 +47,7 @@ func LogViewHandler(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildId, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildId, userId) {
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return
}

View File

@ -2,6 +2,7 @@ package manage
import (
"fmt"
"github.com/TicketsBot/GoPanel/config"
"github.com/TicketsBot/GoPanel/database/table"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/GoPanel/utils/discord"
@ -131,7 +132,7 @@ func WebChatWs(ctx *gin.Context) {
}
// Verify the user has permissions to be here
if !guild.Owner && !table.IsAdmin(guildIdParsed, userId) {
if !utils.Contains(config.Conf.Admins, userIdStr) && !guild.Owner && !table.IsAdmin(guildIdParsed, userId) {
fmt.Println(err.Error())
conn.Close()
return

View File

@ -1,3 +1,5 @@
admins=["217617036749176833"]
[server]
host="0.0.0.0:3000"
baseUrl="http://localhost:3000"

View File

@ -7,6 +7,7 @@ import (
type (
Config struct {
Admins []string
Server Server
Oauth Oauth
MariaDB MariaDB