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 // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -44,7 +44,7 @@ func BlacklistRemoveHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -53,7 +53,7 @@ func LogsHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -46,7 +46,7 @@ func SendMessage(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -48,7 +48,7 @@ func SettingsHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -45,7 +45,7 @@ func TicketListHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -50,7 +50,7 @@ func TicketViewHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -47,7 +47,7 @@ func LogViewHandler(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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 ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
return return
} }

View File

@ -2,6 +2,7 @@ package manage
import ( import (
"fmt" "fmt"
"github.com/TicketsBot/GoPanel/config"
"github.com/TicketsBot/GoPanel/database/table" "github.com/TicketsBot/GoPanel/database/table"
"github.com/TicketsBot/GoPanel/utils" "github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/GoPanel/utils/discord" "github.com/TicketsBot/GoPanel/utils/discord"
@ -131,7 +132,7 @@ func WebChatWs(ctx *gin.Context) {
} }
// Verify the user has permissions to be here // 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()) fmt.Println(err.Error())
conn.Close() conn.Close()
return return

View File

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

View File

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