fix panic
This commit is contained in:
parent
66add26714
commit
a004352933
@ -18,11 +18,7 @@ func BlacklistHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -19,11 +19,7 @@ func BlacklistRemoveHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -18,11 +18,7 @@ func LogsHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -22,11 +22,7 @@ func PanelCreateHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -19,11 +19,7 @@ func PanelDeleteHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -26,11 +26,7 @@ func PanelHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -21,11 +21,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -20,11 +20,7 @@ func SettingsHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -20,11 +20,7 @@ func TicketCloseHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -19,11 +19,7 @@ func TicketListHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -25,11 +25,7 @@ func TicketViewHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -20,11 +20,7 @@ func UpdateSettingsHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -22,11 +22,7 @@ func LogViewHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the guild exists
|
// Verify the guild exists
|
||||||
guildIdStr := ctx.Param("id")
|
guildIdStr := ctx.Param("id")
|
||||||
|
@ -19,11 +19,7 @@ func IndexHandler(ctx *gin.Context) {
|
|||||||
defer store.Save()
|
defer store.Save()
|
||||||
|
|
||||||
if utils.IsLoggedIn(store) {
|
if utils.IsLoggedIn(store) {
|
||||||
userId, err := utils.GetUserId(store)
|
userId := utils.GetUserId(store)
|
||||||
if err != nil {
|
|
||||||
ctx.String(500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
userGuilds := table.GetGuilds(userId)
|
userGuilds := table.GetGuilds(userId)
|
||||||
adminGuilds := make([]objects.Guild, 0)
|
adminGuilds := make([]objects.Guild, 0)
|
||||||
|
@ -2,7 +2,6 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/contrib/sessions"
|
"github.com/gin-gonic/contrib/sessions"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsLoggedIn(store sessions.Session) bool {
|
func IsLoggedIn(store sessions.Session) bool {
|
||||||
@ -15,6 +14,6 @@ func IsLoggedIn(store sessions.Session) bool {
|
|||||||
store.Get("csrf") != nil
|
store.Get("csrf") != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserId(store sessions.Session) (uint64, error) {
|
func GetUserId(store sessions.Session) uint64 {
|
||||||
return strconv.ParseUint(store.Get("userid").(string), 10, 64)
|
return store.Get("userid").(uint64)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user