<<

NAME

ProductOpener::APICurrentUser - API for accessing current user data

DESCRIPTION

This module implements GET /api/v3/current-user/permissions

It returns the current user's permissions (including moderator/admin flags) from the Open Food Facts server database.

Authentication is via a Keycloak Bearer token passed in the Authorization header. The token is validated by process_auth_header() before this function is called, which sets $request_ref->{oidc_user_id} to the authenticated user's ID.

read_current_user_permissions_api ( $request_ref )

Process API V3 GET /api/v3/current-user/permissions requests.

Returns the authenticated user's permissions including moderator and admin flags. Requires a valid Keycloak Bearer token in the Authorization header.

Parameters

$request_ref (input)

Reference to the request object. Must have $request_ref->{oidc_user_id} set by process_auth_header() prior to this call.

Response

On success: { "status": "success", "user": { "userid": "swastik", "name": "Swastik Panigrahi", "moderator": 0, "admin": 0 } }

On error (not authenticated): HTTP 401 with error details On error (invalid sub-action): HTTP 404 with error details

<<