Add more properties to the currentUser() object

56 views Asked by At

Is it possible to add user specific properties (next to userName, fullName, ID) to the directory.currentUser() object?

Result: directory.currentUser()

{
    "result": {
        "userName": "jsmith", 
        "fullName": "John Smith", 
        "ID": "12F169764253481E89F0E4EA8C1D791A"
    }
}

http://livedoc.wakanda.org/HTTP-REST/Authenticating-Users/directorycurrentUser.303-815875.en.html

1

There are 1 answers

0
Jonathan Argentiero On BEST ANSWER

No, you can't. However don't consider it as a drawback:

I suggest you to keep the directory as the authentication service of your application and store your user profile information on another entity (called userProfile, userInfo, client, ...).

This entity should be created just after the signup / first login of the user. It should have an attribute (for example auth) with the same value as the ID retrieved from the directory.currentUser function.

This way when the user makes a login, you fetch his profile searching the entity

where auth = ID

and consume / update his information there.

The solution is very effective if you want to keep separated your authentication system and your model. You will maintain the flexibility to rely on a different authentication system or make a dedicated micro-service later.