mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-21 19:19:22 +08:00
update
This commit is contained in:
24
dag/utils.go
24
dag/utils.go
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user