diff --git a/app/http/endpoints/manage/blacklist.go b/app/http/endpoints/manage/blacklist.go index 8f153d5..789f72a 100644 --- a/app/http/endpoints/manage/blacklist.go +++ b/app/http/endpoints/manage/blacklist.go @@ -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 } diff --git a/app/http/endpoints/manage/blacklistremove.go b/app/http/endpoints/manage/blacklistremove.go index 937a965..8c63907 100644 --- a/app/http/endpoints/manage/blacklistremove.go +++ b/app/http/endpoints/manage/blacklistremove.go @@ -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 } diff --git a/app/http/endpoints/manage/logs.go b/app/http/endpoints/manage/logs.go index 8e19944..e12dd8b 100644 --- a/app/http/endpoints/manage/logs.go +++ b/app/http/endpoints/manage/logs.go @@ -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 } diff --git a/app/http/endpoints/manage/sendmessage.go b/app/http/endpoints/manage/sendmessage.go index 3867842..e49ba7f 100644 --- a/app/http/endpoints/manage/sendmessage.go +++ b/app/http/endpoints/manage/sendmessage.go @@ -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 } diff --git a/app/http/endpoints/manage/settings.go b/app/http/endpoints/manage/settings.go index c8caeef..4abaf06 100644 --- a/app/http/endpoints/manage/settings.go +++ b/app/http/endpoints/manage/settings.go @@ -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 } diff --git a/app/http/endpoints/manage/ticketlist.go b/app/http/endpoints/manage/ticketlist.go index bb90937..d885040 100644 --- a/app/http/endpoints/manage/ticketlist.go +++ b/app/http/endpoints/manage/ticketlist.go @@ -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 } diff --git a/app/http/endpoints/manage/ticketview.go b/app/http/endpoints/manage/ticketview.go index ec75d5c..461433c 100644 --- a/app/http/endpoints/manage/ticketview.go +++ b/app/http/endpoints/manage/ticketview.go @@ -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 } diff --git a/app/http/endpoints/manage/viewlog.go b/app/http/endpoints/manage/viewlog.go index a326243..36eb5a0 100644 --- a/app/http/endpoints/manage/viewlog.go +++ b/app/http/endpoints/manage/viewlog.go @@ -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 } diff --git a/app/http/endpoints/manage/webchatws.go b/app/http/endpoints/manage/webchatws.go index e460908..2b00d30 100644 --- a/app/http/endpoints/manage/webchatws.go +++ b/app/http/endpoints/manage/webchatws.go @@ -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 diff --git a/config.toml.example b/config.toml.example index 5e2c376..35ea8dd 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,3 +1,5 @@ +admins=["217617036749176833"] + [server] host="0.0.0.0:3000" baseUrl="http://localhost:3000" diff --git a/config/config.go b/config/config.go index a68261e..1e2b581 100644 --- a/config/config.go +++ b/config/config.go @@ -7,6 +7,7 @@ import ( type ( Config struct { + Admins []string Server Server Oauth Oauth MariaDB MariaDB