diff --git a/controller/controller.go b/controller/controller.go index 7ad659c..b84527e 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -5,6 +5,7 @@ import ( "git.lumeweb.com/LumeWeb/portal/logger" "github.com/kataras/iris/v12" "go.uber.org/zap" + "strconv" ) func tryParseRequest(r interface{}, ctx iris.Context) (interface{}, bool) { @@ -70,3 +71,16 @@ func (c Controller) respondJSON(data interface{}) { logger.Get().Error("failed to generate response", zap.Error(err)) } } + +func getCurrentUserId(ctx iris.Context) uint { + usr := ctx.User() + + if usr == nil { + return 0 + } + + sid, _ := usr.GetID() + userID, _ := strconv.Atoi(sid) + + return uint(userID) +}