How to inject User class as dependency?
You don't have to inject services in the controller, because ControllerBase already provides the services needed. So this should work:

$user = $this-&gt;entityTypeManager()-&gt;getStorage('user')-&gt;load($this-&gt;currentUser()-&gt;id());




For other services not included in ControllerBase, see How do I use dependency injection on \Drupal::moduleHandler() to a Controller?