Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Benmuiruri committed Jan 16, 2025
1 parent 33ba848 commit 61f9a0d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/resources/translations/messages-ne.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ translation.add = नयाँ अनुवाद कुञ्जी थप्
translation.key = अनुवाद कुञ्जी
unique.id = आईडी
unknown.contact = अपरिचित सम्पर्क
update.password.help = प्रयोगकर्ताले आफ्नो अर्को लगइनमा आफ्नो पासवर्ड रिसेट गर्न आवश्यक हुनेछ
update.password.help = यो प्रयोगकर्ताले अर्को पटक लगइन गर्दा आफ्नो पासवर्ड पुन: सेट गर्नुपर्नेछ।
upgrade = अपग्रेड
upgrade.description = तपाईँको एपलाई कुनै रिलीज, बीटा, वा ब्रान्चमा अपग्रेड गर्न, पहिलो चरणको रूपमा स्टेज गर्न सिफारिस गरिन्छ। यसले प्रयोगकर्ताहरूलाई अवरोध नगरी पृष्ठभूमिमा इन्स्टलेसन तयारी गर्छ। स्टेजिंग पुरा भएपछि, अपग्रेडको लागि 'इन्स्टल गर्नुहोस्' क्लिक गर्नुहोस्। यो पछि, यसलाई पहिलाकै अवस्थामा लैजान सकिँदैन, त्यसैले कृपया तपाईँको डेटा ब्याकअप गरिएको छ र तपाईँका प्रयोगकर्ताहरूलाई सेवा अवरुद्ध रहने बारे जानकारी दिइएको छ भन्ने निश्चित गर्नुहोस्।
upload = अपलोड
Expand Down
9 changes: 2 additions & 7 deletions shared-libs/user-management/src/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ const isPasswordChangeRequired = (user, data, fullAccess) => {
return !roles.hasAllPermissions(userRoles, ['can_skip_password_change']);
};

const getUserUpdates = async (user, data, fullAccess = false) => {
const getUserUpdates = (user, data, fullAccess = false) => {
const ignore = ['type', 'place', 'contact'];
const updatedUser = { ...user, type: 'user' };

Expand Down Expand Up @@ -561,13 +561,8 @@ const missingFields = data => {
const getUpdatedUserDoc = async (username, data, fullAccess) => {
return getUserDoc(username, 'users')
.then(async doc => {
const baseUser = {
...doc,
name: username,
type: 'user',
};
return {
...baseUser,
...doc,
...(await getUserUpdates(doc, data, fullAccess)),
_id: createID(username)
};
Expand Down
28 changes: 23 additions & 5 deletions shared-libs/user-management/test/unit/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,10 @@ describe('Users service', () => {
const data = {
language: 'es'
};
db.users.get.resolves({});
db.users.get.resolves({
name: 'paul',
type: 'user'
});
db.medic.get.resolves({});
const medicPut = db.medic.put.resolves({});
const usersPut = db.users.put.resolves({});
Expand All @@ -3151,7 +3154,10 @@ describe('Users service', () => {
const data = {
language: 'es'
};
db.users.get.resolves({});
db.users.get.resolves({
name: 'paul',
type: 'user'
});
db.medic.get.resolves({});
const medicPut = db.medic.put.resolves({});
const usersPut = db.users.put.resolves({});
Expand All @@ -3178,7 +3184,11 @@ describe('Users service', () => {
admin2: 'password_2',
});

db.users.get.resolves({});
db.users.get.resolves({
name: 'admin2',
type: 'user',
roles: ['_admin']
});
db.medic.get.resolves({});
db.medic.put.resolves({});
db.users.put.resolves({});
Expand All @@ -3202,7 +3212,10 @@ describe('Users service', () => {
admin1: 'password_1',
admin2: 'password_2',
});
db.users.get.resolves({});
db.users.get.resolves({
name: 'admin2',
type: 'user'
});
db.medic.get.resolves({});
db.medic.put.resolves({});
db.users.put.resolves({});
Expand Down Expand Up @@ -3231,7 +3244,10 @@ describe('Users service', () => {
admin1: 'password_1',
admin2: 'password_2',
});
db.users.get.resolves({});
db.users.get.resolves({
name: 'anne',
type: 'user'
});
db.medic.get.resolves({});
db.medic.put.resolves({});
db.users.put.resolves({});
Expand Down Expand Up @@ -3684,6 +3700,7 @@ describe('Users service', () => {
const updates = { token_login: true, phone: '+40 755 89-89-89' };
db.medic.get.onFirstCall().resolves({
_id: 'org.couchdb.user:sally',
name: 'sally',
type: 'user-settings',
roles: ['a', 'b', 'mm-online'],
phone: '123',
Expand All @@ -3697,6 +3714,7 @@ describe('Users service', () => {
});
db.users.get.onFirstCall().resolves({
_id: 'org.couchdb.user:sally',
name: 'sally',
type: 'user',
roles: ['a', 'b', 'mm-online'],
});
Expand Down

0 comments on commit 61f9a0d

Please sign in to comment.