KeycloakClientBundle icon indicating copy to clipboard operation
KeycloakClientBundle copied to clipboard

If there is no access to a field OR field does not exist - user returned as null

Open flesheater opened this issue 1 year ago • 0 comments

If here https://github.com/mainick/KeycloakClientBundle/blob/main/src/DTO/UserRepresentationDTO.php

            id: $data['sub'],
            username: $data['preferred_username'],
            emailVerified: $data['email_verified'],
            name: $data['name'],
            firstName: $data['given_name'],
            lastName: $data['family_name'],
            email: $data['email'],
            enabled: $data['enabled'] ?? null,
            createdTimestamp: $data['createdTimestamp'] ?? null,
            updatedAt: $data['updated_at'] ?? null,
            attributes: $data['attributes'] ?? null,
            realmRoles: count($realm_roles) ? $realm_roles : null,
            clientRoles: count($client_roles) ? $client_roles : null,
            applicationRoles: count($application_roles) ? $application_roles : null,
            groups: count($groups) ? $groups : null,
            scope: count($scope) ? $scope : null,
        );  

e.g. the field $data['given_name'] does not exist - the user is being returned as null.

An easy fix would be e.g. if the given_name, family_name are getting empty strings or if they do not exist/not set to set them as empty strings.

flesheater avatar Feb 03 '25 13:02 flesheater