Display the data of a logged in user

This is how I do it in CakePHP 4.1:

$user = $this->request->getAttribute('identity');

Then, you can access any of the user table fields with $user->FIELDNAME, for example, $user->email