Overhaul The User Management Dashboard

I will notify you, when I finish add things that you requested :slight_smile:

I plan to finish it during this day

1 Like

Hi, Robert!

Current project status: for the last days Iā€™ve done:

  • implemented search (filter) by user primary email;
  • Removed column ā€˜groupsā€™ from list of available to display in data grid;
  • Added permission checking middleware (as you asked);
  • Integrated option to re-save user in LDAP/Mongo
  • Implemented option to manage email list

To do:

  • Notifications (on user update, remove, etc)
  • Errors handling
  • Fix warning on Edit User page escape button click;
  • Implement option to edit user via url params (for example, user-dashboard?username=peter will open edit user ā€˜peterā€™ window)

What else I have to do? Your proposals?

Thanks, Dmytro.

What is Notifications for? I donā€™t want to modify the user and send a needless email. Just tell me it was successful, thatā€™s enough. If Iā€™m editing the user, that means they have a helpdesk case and I will communicate there.

I mean, popup windows on the admin page after update/delete actions :slight_smile:

Oh, okay, that makes much more sense :slight_smile:

Implemented next options:

Also, I found some bug:

when I am calling UserSchema.update({ _id: user._id }, user)

user data successfully updated in Mongo, but not in LDAP. Itā€™s looks like that when we calling ā€˜updateā€™ ā€˜presaveā€™ hook didnā€™t called. So, what is the right way to update user in Mongo, to call ā€˜presaveā€™ hook?

Itā€™s funny to see, that our discussion became one of the most replied on OpenMRS Talk :smile: :smile:

https://talk.openmrs.org/?order=posts

2 Likes

Try calling save .

It makes sense since weā€™ve been among the few that actually had all communication this summer in the open, and in a fully transparent manner, which is the way Open Source projects should be done! For that, I actually am happy.

2 Likes

I tried that before, but always get an error: [2016-08-18 08:54:54.389] [INFO] console - { [MongoError: insertDocument :: caused by :: 11000 E11000 duplicate key error index: openmrsid.users.$_id_ dup key: { : ObjectId('57b0dd6aaa37171a002a917e') }] name: 'MongoError', code: 11000, err: 'insertDocument :: caused by :: 11000 E11000 duplicate key error index: openmrsid.users.$_id_ dup key: { : ObjectId(\'57b0dd6aaa37171a002a917e\') }' } MongoError: insertDocument :: caused by :: 11000 E11000 duplicate key error index: openmrsid.users.$_id_ dup key: { : ObjectId('57b0dd6aaa37171a002a917e') } at Object.toError (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/utils.js:114:11) at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection/core.js:116:29 at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1197:7 at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1905:9 at Server.Base._callHandler (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:453:41) at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:488:18 at MongoReply.parseBody (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5) at null.<anonymous> (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:446:20) at emitOne (events.js:90:13) at emit (events.js:182:7) at null.<anonymous> (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13) at emitTwo (events.js:100:13) at emit (events.js:185:7) at Socket.<anonymous> (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:440:22) at emitOne (events.js:90:13) at Socket.emit (events.js:182:7)

So, it looks like that save can be used only for creating NEW documents, not for update.

I see only one solution to fix that - call ldap.updateUser manually after User.update();

UPD - found another - call Model.findOne, and than save

What does the ā€˜lockedā€™ property in Mongo scheme means? I believe, when user is ā€˜lockedā€™ we cannot update most his properties (username, primaryEmail, firstName, lastName, displayName, password), because they are stored in LDAP

the locked property is initially set when a user registers but does not verify their account; once they verify their account, it is toggled to false.

We cannot change usernames, we SHOULD be able to change other things though. Iā€™ve changed peopleā€™s primary emails ā€“ in fact you can do that now in dashboard. You can also change your nameā€¦The only immutable thing you CANNOT change is username.

1 Like

I registered multiple users, activated them via email links, but property ā€˜lockedā€™ left ā€˜trueā€™ for most of them. Is it a bug?

That should not beā€¦locked should be false once you verify.

Found a problem on my side, fixed. Thanks for you answer)

But what about if admin manually set ā€˜lockedā€™ to true? While itā€™s locked, we must disable option to edit user fields? Or just unset flag ā€˜lockedā€™ before save?

If it is locked, we should be able to unlock it BUT if we do that ā€“ it should add the groups for us. It might be worthwhile to disable the text fields if theyā€™re locked.

Soon as I unlock, the text fields should be editable :slight_smile:

Also FYI, you donā€™t have to allow for creating new users ā€“ itā€™s a nice to have but not entirely necessary as itā€™s something we rarely ever do, if at all.

1 Like

Okay, thanks

Another question - for now, we have boolean fields (inLDAP, locked) in database, but on UI I dispplay them as ā€˜Yes/Noā€™, so I should convert them when getting from server from boolean to string, and vice versa when send them to server. Is it possible to left them boolean even on UI (will be displayed in Table as ā€˜true/falseā€™) to throw out converting? Later we can thought about how to display them on UI in more nice way

I kinda like the idea of the sliderā€¦ itā€™s clear to me ā€“ so long as itā€™s intuitive, use your judgement. Iā€™m going to sleep.

1 Like

Thanks for the tips! Good night

1 Like

Can you explain, why this error can happen?

[2016-08-19 00:08:39.267] [ERROR] discourse-sso - [Error: options.uri is a required argument] Error: options.uri is a required argument at Request.init (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/request/request.js:233:31) at new Request (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/request/request.js:129:8) at request (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/request/index.js:55:10) at syncUser (/home/invercity/projects/webstorm/openmrs-contrib-id/app/user-modules/openmrs-contrib-id-sso/lib/discourse.js:50:3) at model.<anonymous> (/home/invercity/projects/webstorm/openmrs-contrib-id/app/user-modules/openmrs-contrib-id-sso/lib/discourse.js:80:3) at emitTwo (events.js:92:20) at model.emit (events.js:172:7) at handleSave (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/lib/model.js:132:10) at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/lib/utils.js:408:16 at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection/core.js:128:9 at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1197:7 at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1905:9 at Server.Base._callHandler (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:453:41) at /home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:488:18 at MongoReply.parseBody (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5) at null.<anonymous> (/home/invercity/projects/webstorm/openmrs-contrib-id/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:446:20)

It appears when I am trying to save NEW user to Mongo (if user exists in ldap but not in Mongo). Error appears, but user saved successfully :slight_smile:

Also ,question: if user is missed in Mongo, but exists in LDAP, should it be locked after saving to Mongo? Or make it unlocked automatically (with adding basic groups)?