Retrieve data for current user

0
I have this domain model: Customer with attributes Adress, ZIP etc. and the generalization Person with attribute Name (This is for the reason that there are also other entities with this attribute in the model). A customer can login on his own page and see his information (Name, adress etc.). How do I retrieve this information from the database and display it in a dataview for this specific customer(or something else)?
asked
2 answers
3

An example of this can be found in the Administration module that is available in a new project by default. The microflow ManageMyAccount that opens the MyAccount page show the use of $currentUser. This variable is available in any microflow when security is enabled. After casting it to the specialization you need, you can retrieve the required entities in the same way as you would do it from any other object.

Personally, I would connect to (or inherit from) Administration.Account, instead of System.User, to stay away from the System module and make use of the build-in user management of the Administration module.

answered
0

You need to associate your 'Customer' or 'Person' entity to the System.User Entity or one of its specializations. You can then use a Retrieve of the User object with which the current user is logged in using the xPath [id = $currentUser/id].

Via association, you can then get the Customer or Person object and data.

answered