(solved) Hidden field is exposed

I have a User entity that’s exposing the password field even when set to hidden:

class User extends Entity implements IdentityInterface
{

protected array $_accessible = [
    'email' => true,
    'picture' => true
];

protected array $_hidden = ['password'];

The call to grab the user is:

$user = $this->Users->findById($this->request->getSession()->read(‘identity.user.id’), contain: [‘Roles’])->first();

That’s it. No idea why it’s being exposed.

the _hidden array doens’t prevent you from accessing the property or printing it out directly.

All it does is prevent it from being outputted via serialization, e.g.

pr($entity->toArray());

See Entities - 4.x

2 Likes

Thanks for pointing that out. Not sure how I missed that.