This commit is contained in:
@@ -3,8 +3,11 @@ package inmemory
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"errors"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
"github.com/authorizerdev/authorizer/server/memorystore/providers/redis"
|
||||
)
|
||||
|
||||
// SetUserSession sets the user session for given user identifier in form recipe:user_id
|
||||
@@ -119,3 +122,25 @@ func (c *provider) GetBoolStoreEnvVariable(key string) (bool, error) {
|
||||
}
|
||||
return res.(bool), nil
|
||||
}
|
||||
|
||||
// GetUserAppDataFromRedis retrieves user profile and follows from Redis, combines them into a JSON format,
|
||||
// and assigns the JSON string to the provided user's ID.
|
||||
func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) {
|
||||
redisURL := os.Getenv(constants.EnvKeyRedisURL)
|
||||
if redisURL == "" {
|
||||
return "", errors.New("Redis URL not found")
|
||||
}
|
||||
|
||||
log.Info("Initializing Redis provider")
|
||||
red, err := redis.NewRedisProvider(redisURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to initialize Redis provider: %w", err)
|
||||
}
|
||||
|
||||
combinedData, err := red.GetUserAppDataFromRedis(userId)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get Redis app data: %w", err)
|
||||
}
|
||||
|
||||
return combinedData, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user