When you need to get the active logged in user in your controller, the most common way would be injecting Principal to your controller methods.
But when you need this to be done in multiple methods, you may be looking for a cleaner approach like injecting the exact User instead of Principal object.
To inject your user object (e.g. TutorialUser) follow these steps.
TutorialUser to implement
Create the annotation you want.
Make sure to add the
@AuthenticationPrincipal annotation. Otherwise it won’t work.
Then you can use this annotation with your User object in your controllers.
You can check an example code at my github page.