diff options
Diffstat (limited to 'backend/graphql/resolver/auth_helpers.go')
| -rw-r--r-- | backend/graphql/resolver/auth_helpers.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/backend/graphql/resolver/auth_helpers.go b/backend/graphql/resolver/auth_helpers.go new file mode 100644 index 0000000..dcc09fb --- /dev/null +++ b/backend/graphql/resolver/auth_helpers.go @@ -0,0 +1,29 @@ +package resolver + +import ( + "context" + "errors" + "fmt" + + "github.com/labstack/echo/v4" + appcontext "undef.ninja/x/feedaka/context" +) + +// getUserIDFromContext retrieves the authenticated user ID from context +// This is a wrapper around the GetUserID function from the context package +func getUserIDFromContext(ctx context.Context) (int64, error) { + userID, ok := appcontext.GetUserID(ctx) + if !ok { + return 0, fmt.Errorf("authentication required") + } + return userID, nil +} + +// Helper function to get Echo context from GraphQL context +func getEchoContext(ctx context.Context) (echo.Context, error) { + echoCtx, ok := ctx.Value("echo").(echo.Context) + if !ok { + return nil, errors.New("echo context not found") + } + return echoCtx, nil +} |
