fix permission check
This commit is contained in:
parent
61c0fdd8df
commit
9d83d3b668
@ -44,8 +44,8 @@ func BlacklistHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func BlacklistRemoveHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ func LogsHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ func PanelCreateHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ func PanelDeleteHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ func PanelHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ func SettingsHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ func TicketCloseHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func TicketListHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ func TicketViewHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func UpdateSettingsHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ func LogViewHandler(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
ctx.Redirect(302, config.Conf.Server.BaseUrl) // TODO: 403 Page
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,8 @@ func WebChatWs(ctx *gin.Context) {
|
|||||||
|
|
||||||
// Verify the user has permissions to be here
|
// Verify the user has permissions to be here
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildIdParsed, userId, isAdmin)
|
go utils.IsAdmin(guild, guildIdParsed, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if !<-isAdmin {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
|
@ -33,7 +33,7 @@ func IndexHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isAdmin := make(chan bool)
|
isAdmin := make(chan bool)
|
||||||
go utils.IsAdmin(store, guild, guildId, userId, isAdmin)
|
go utils.IsAdmin(guild, guildId, userId, isAdmin)
|
||||||
if <-isAdmin {
|
if <-isAdmin {
|
||||||
adminGuilds = append(adminGuilds, guild)
|
adminGuilds = append(adminGuilds, guild)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
var roleCache = cache.New(time.Minute, time.Minute)
|
var roleCache = cache.New(time.Minute, time.Minute)
|
||||||
|
|
||||||
func IsAdmin(store sessions.Session, guild objects.Guild, guildId, userId int64, res chan bool) {
|
func IsAdmin(guild objects.Guild, guildId, userId int64, res chan bool) {
|
||||||
if Contains(config.Conf.Admins, strconv.Itoa(int(userId))) {
|
if Contains(config.Conf.Admins, strconv.Itoa(int(userId))) {
|
||||||
res <- true
|
res <- true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user