This commit is contained in:
sujit
2025-10-01 22:14:08 +05:45
parent 331c9aa81a
commit fd6c24a44a
4 changed files with 183 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"sync"
"time"
"github.com/gofiber/fiber/v2/middleware/session"
"github.com/oarkflow/json"
"github.com/oarkflow/mq"
dagstorage "github.com/oarkflow/mq/dag/storage"
@@ -600,3 +601,26 @@ func (h *ActivityAlertHandler) HandleAlert(alert Alert) error {
}
return nil
}
func CanSession(ctx context.Context, key string) bool {
sess, ok := ctx.Value("session").(*session.Session)
if !ok || sess == nil {
return false
}
if authenticated, exists := sess.Get(key).(bool); exists && authenticated {
return true
}
return false
}
func GetSession(ctx context.Context, key string) (any, bool) {
sess, ok := ctx.Value("session").(*session.Session)
if !ok || sess == nil {
return nil, false
}
value := sess.Get(key)
if value != nil {
return value, true
}
return nil, false
}