Expand the CurrentAuthentication result

There is a way the CurrentAuthentication get the new properties I add to the User entity?, so I cant get this properties from the session?.

You don’t need to expand anything, CurrentAuthentication.getUser() returns the type of your User entity, so you can safely cast to it:

User user = (User) currentAuthentication.getUser();

BTW, take a look at the Code Snippets palette in Studio.

Thanks konstantine, I already knew about that, but even when this give me a full object User, with all atributtes, the extra atributtes remains null. Maybe because a default fetchPlan?. For now I am using a function that use currentAthentication and datamanager to retrive the full object. However my problem comes with the constraints, because this make my contraints more complicated that it should (low performance too), so the thing is I want to have this extra porperties in the user session directly.

BTW, I already had checked the code snippets, It’s pretty cool although I’m not use to use code snippets, but good work.

What kind of attributes do you have in User? And how are you trying to access them?

In my experiments, even references are available in the User instance obtained via CurrentAuthentication due to lazy loading. Like this:

User user = (User) currentAuthentication.getUser();
Department department = user.getDepartment();
log.info("Department: " + department.getName());

I’ve created a proyect test for you. Here:
Session.zip (266.6 KB)
You have 2 end-points test it, is not working for me.
However even this is a pain, it is more painfull with constraints, becasuse I can’t do :current_user_myProp
PD:The api pass an cliente :
jmix.security.oauth2.client-id=test
jmix.security.oauth2.client-secret={noop}test

And you can user admin/admin as user. I have create a extra user with a liquibase with a extra prop, I hope will work.
Cheers.

Thank you for the test project.
Initially, you didn’t mention that you invoke a service through REST, that’s why I couldn’t reproduce the problem.
Created issue: https://github.com/jmix-framework/jmix/issues/948

Regards,
Konstantin

Sorry I forgot metion It was REST, I will keep in mind for next time, I always fortgot it is a different scope in jmix.

No problem. Thank you for spotting the issue!