Trying to retrieve the ContentType slug using $contentTypeSlug = $this->getExtension()->getExtConfig('contenttype', $user->getRoles()[0]); in FrontendUsersProfileController.php throws the exception Call to a member function getRoles() on null.
This happens when a user tries to access profile routes without an active session, either because it expired or was invalidated.

I have found a solution for this issue and will share for review.