Admin user doesn't have a username.

Hello People,

We are working on enabling bahmni appointments to run on OpenMRS. This application leverages logged-in user’s username. It sets the current logged-in username in the cookies and uses it later.

This works for all the users but the admin user. We see that admin user doesn’t have a username and the cookie is set to null. We checked out on bahmni-demo and found out that the username for admin is populated but not on OpenMRS Demo.

Any specific reason why the admin user doesn’t have a username?

Thank you!

CC: @mksd @angshuonline @dkayiwa @rrameshbtech

bumped to bahmni category

Are you able to do user.toString()?

@dkayiwa, We don’t have hold of the user java object. We are using the session api /openmrs/ws/rest/v1/session?v=custom:(uuid,username) to figure out if the session is valid and to get the logged-in user’s username.

Now while it works for all the other users, for admin we get it as null. The reason for this is that the admin user doesn’t have username populated in the database. We wanted to know why the admin user doesn’t get a username.

Not for any reason that am aware of. All i can say is that it looks like an oversight. I have seen quite a number of people get into trouble over the null username for this admin account. Therefore, i would recommend fixing this: in the same way as it was done for the daemon account:

1 Like

I can create a card and raise a PR. Just help me understand one thing though, since it is a change-set ideally, I should create a new change-set where I populate this specific value. Unless openmrs have some guidelines to edit the existing changeset with validChecksum.

I will create a ticket in the meantime.

EDIT: Created a card here:

I have created a card here. Though for some reason not getting an option to claim ticket.

liquibase-core-data.xml is run only on fresh installations. So you can just edit that file and simply add a username.

Thanks for the information. Shouldn’t we add another changeset in liquibase-update-to-2.3.xml which updates it for the existing installation?

Correct me if I am wrong.

It would be the liquibase-update-to-2.4.xml file. In that case, it would not be necessary to modify liquibase-core-data.xml

I might not be really aware of how openmrs liquibase piece works. As of now, I don’t see a liquibase-update-to-2.4.xml. Should I create one?

Other question is, does this mean it will not be part of 2.3 release/SNAPSHOTs?

Yes you can always create one if it does not exist. Correct, it would not be part of the platform 2.3 release. If you plan to backport it to 2.3, then you can put it in the liquibase-update-to-2.3.xml file.

Raise a PR here. Added it to the issue as well.