define context keysessionid using go-vise --withcontext

This commit is contained in:
Carlosokumu 2025-01-04 10:40:26 +03:00
parent 3ce1435591
commit 62f3681b9e
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953

View File

@ -28,7 +28,7 @@ import (
) )
var ( var (
logg = logging.NewVanilla().WithDomain("ussdmenuhandler") logg = logging.NewVanilla().WithDomain("ussdmenuhandler").WithContextKey("session-id")
scriptDir = path.Join("services", "registration") scriptDir = path.Join("services", "registration")
translationDir = path.Join(scriptDir, "locale") translationDir = path.Join(scriptDir, "locale")
) )
@ -122,9 +122,12 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
h.st.Code = []byte{} h.st.Code = []byte{}
} }
sessionId, _ := ctx.Value("SessionId").(string) sessionId, ok := ctx.Value("SessionId").(string)
flag_admin_privilege, _ := h.flagManager.GetFlag("flag_admin_privilege") if ok {
context.WithValue(ctx, "session-id", sessionId)
}
flag_admin_privilege, _ := h.flagManager.GetFlag("flag_admin_privilege")
isAdmin, _ := h.adminstore.IsAdmin(sessionId) isAdmin, _ := h.adminstore.IsAdmin(sessionId)
if isAdmin { if isAdmin {