feat: add getCurrentUserId helper function
This commit is contained in:
parent
40309311bd
commit
29d6db2009
|
@ -5,6 +5,7 @@ import (
|
||||||
"git.lumeweb.com/LumeWeb/portal/logger"
|
"git.lumeweb.com/LumeWeb/portal/logger"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func tryParseRequest(r interface{}, ctx iris.Context) (interface{}, bool) {
|
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))
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue