Skip to content

Commit

Permalink
feat(#9547): require password reset on first time login and admin pas…
Browse files Browse the repository at this point in the history
…sword update (#9731)
  • Loading branch information
Benmuiruri authored Jan 31, 2025
1 parent 8e6ed11 commit 67b5330
Show file tree
Hide file tree
Showing 42 changed files with 1,449 additions and 201 deletions.
8 changes: 7 additions & 1 deletion admin/src/js/controllers/edit-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ angular
});
};

const validateSkipPasswordPermission = () => {
$scope.skipPasswordChange = chtDatasource.v1.hasPermissions(
['can_skip_password_change'], $scope.editUserModel.roles, $scope.permissions
);
};

const formatDate = (settings, date) => {
const format = settings.reported_date_format || 'DD-MMM-YYYY HH:mm:ss';
return moment(date).format(format);
Expand Down Expand Up @@ -151,6 +157,7 @@ angular
this.setupPromise = determineEditUserModel()
.then(model => {
$scope.editUserModel = model;
validateSkipPasswordPermission();
})
.catch(err => {
$log.error('Error determining user model', err);
Expand Down Expand Up @@ -298,7 +305,6 @@ angular
return userHasPermission;
};


const isOnlineUser = (roles) => {
if (!$scope.roles) {
return true;
Expand Down
1 change: 1 addition & 0 deletions admin/src/templates/edit_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
class="form-group"
ng-class="{ 'has-error': errors.password, 'required': !editUserModel.id, 'hidden': allowTokenLogin && (editUserModel.token_login || (editUserModel.token_login !== false && editUserModel.tokenLoginEnabled)) }">
<label for="edit-password" translate>Password</label>
<div class="text-muted" ng-if="!skipPasswordChange" translate>update.password.help</div>
<div class="password-input-group">
<input
id="edit-password"
Expand Down
34 changes: 34 additions & 0 deletions admin/tests/unit/controllers/edit-user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('EditUserCtrl controller', () => {
},
permissions: {
can_have_multiple_places: ['community-health-assistant'],
can_skip_password_change: ['community-health-assistant'],
},
});
http = { get: sinon.stub() };
Expand Down Expand Up @@ -864,4 +865,37 @@ describe('EditUserCtrl controller', () => {
});
});
});

describe('skipPasswordChange', () => {
let user;

beforeEach(() => {
user = {
_id: 'user.id',
name: 'user.name',
fullname: 'user.fullname',
email: '[email protected]',
phone: 'user.phone',
facility_id: 'abc',
contact_id: 'xyz',
language: 'zz',
};
});

it('should set skipPasswordChange to false if user does not have can_skip_password_change permission', () => {
user.roles = ['supervisor'];

return mockEditAUser(user).setupPromise.then(() => {
chai.expect(scope.skipPasswordChange).to.equal(false);
});
});

it('should set skipPasswordChange to true if user has can_skip_password_change permission', () => {
user.roles = ['community-health-assistant'];

return mockEditAUser(user).setupPromise.then(() => {
chai.expect(scope.skipPasswordChange).to.equal(true);
});
});
});
});
8 changes: 8 additions & 0 deletions api/resources/translations/messages-ar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ bulkdelete.confirm.title = هل تريد حذف السجل؟
bulkdelete.confirm.title.plural = هل تريد حذف السجلات المحدّدة؟
call = اتصال
case_id = معرّف الحالة
change.password.confirm.password = تأكيد كلمة المرور
change.password.hint = والأرقام والأحرف الخاصة.استخدم الأحرف الكبيرة
change.password.new.password = كلمة المرور الجديدة
change.password.submit = تغيير كلمة المرور
change.password.title = تغيير كلمة المرور
child_birth_date = تاريخ ميلاد الطفل
child_birth_outcome = حصيلة ميلاد الطفل
child_birth_weight = وزن الطفل عند الولادة
Expand Down Expand Up @@ -965,8 +970,11 @@ partner.logo.upload = تحميل شعار الشريك
partner.name.field = اسم الشريك
partner.supporting = الشركاء الداعمون
partner.tab.partners = الشركاء
password.current.incorrect = كلمة المرور الحالية غير صحيحة
password.incorrect = كلمة المرور غير صحيحة.
password.length.minimum = يجب أن تكون كلمة المرور مؤلفة على الأقل من {{minimum}} حرفاً.
password.must.match =وتأكيد كلمة المرور يجب أن تتطابق كلمة المرور
password.same = الحالية تكون مختلفة عن كلمة المرور كلمة المرور الجديدة يجب أن
password.update = تحديث كلمة المرور
password.weak = كلمة المرور سهلة جداً ليتم تخمينها. يرجى تضمين مجموعة متنوعة من الحروف لجعلها أكثر تعقيداً.
patient\ id\ not\ found\ response = يُرجى إرسال الرسالة التالية إذا اجتازت جميع عمليات التحقق ولكن لم يتم العثور على معرّف المريضـ(ـة).
Expand Down
13 changes: 11 additions & 2 deletions api/resources/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ bulkdelete.confirm.title = Delete record?
bulkdelete.confirm.title.plural = Delete selected records?
call = Call
case_id = Case ID
change.password.confirm.password = Confirm password
change.password.hint = Use uppercase letters, numbers, and special characters.
change.password.new.password = New password
change.password.submit = Change password
change.password.title = Change your password
child_birth_date = Child birth date
child_birth_outcome = Child birth outcome
child_birth_weight = Child birth weight
Expand Down Expand Up @@ -654,8 +659,8 @@ enketo.geopicker.altitude = altitude (m)
enketo.geopicker.closepolygon = close polygon
enketo.geopicker.kmlcoords = KML coordinates
enketo.geopicker.kmlpaste = paste KML coordinates here
enketo.geopicker.latitude = latitude (x.y °)
enketo.geopicker.longitude = longitude (x.y °)
enketo.geopicker.latitude = latitude (x.y °)
enketo.geopicker.longitude = longitude (x.y °)
enketo.geopicker.points = points
enketo.geopicker.searchPlaceholder = search for place or address
enketo.geopicker.removePoint = This will completely remove the current geopoint from the list of geopoints and cannot be undone. Are you sure you want to do this?
Expand Down Expand Up @@ -964,8 +969,11 @@ partner.logo.upload = Upload partner logo
partner.name.field = Partner name
partner.supporting = Supporting partners
partner.tab.partners = Partners
password.current.incorrect = Current password is not correct
password.incorrect = Password is not correct.
password.length.minimum = The password must be at least {{minimum}} characters long.
password.must.match = Password and confirm password must match
password.same = New password must be different from current password
password.update = Update password
password.weak = The password is too easy to guess. Include a range of characters to make it more complex.
patient\ id\ not\ found\ response = Send the following response message if the validations pass but the Medic ID is not located.
Expand Down Expand Up @@ -1272,6 +1280,7 @@ translation.add = Add new translation key
translation.key = Translation key
unique.id = Unique ID
unknown.contact = Unknown contact
update.password.help = User will be required to reset their password on their next login
upgrade = Upgrade
upgrade.description = To upgrade your application to a specific release, beta, or branch, it is recommended that you stage first. This allows for background work to be done to prepare the installation without interrupting users. Once staging is complete, click Install to proceed with the upgrade. This action cannot be undone, so please make sure your data has been backed up and your users are notified of downtime.
upload = Upload
Expand Down
9 changes: 9 additions & 0 deletions api/resources/translations/messages-es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ bulkdelete.confirm.title = ¿Eliminar el registro?
bulkdelete.confirm.title.plural = ¿Eliminar registros seleccionados?
call = Llamar
case_id = Identificación del caso
change.password.confirm.password = Confirmar contraseña
change.password.hint = Utilice letras mayúsculas, números y caracteres especiales.
change.password.new.password = Nueva contraseña
change.password.submit = Cambiar la contraseña
change.password.title = Cambiar contraseña
child_birth_date = Fecha de nacimiento del niño
child_birth_outcome = Resultado del nacimiento del niño
child_birth_weight = Peso del niño al nacer
Expand Down Expand Up @@ -964,8 +969,11 @@ partner.logo.upload = Subir logo del socio
partner.name.field = Nombre del socio
partner.supporting = Socios que está apoyando
partner.tab.partners = Socios
password.current.incorrect = La contraseña actual no es correcta
password.incorrect = La contraseña no es correcta.
password.length.minimum = La contraseña debe tener al menos {{minimum}} caracteres.
password.must.match = Las contraseñas y la contraseña de confirmación deben coincidir
password.same = La nueva contraseña debe ser diferente de la contraseña actual
password.update = Actualizar contraseña
password.weak = La contraseña es demasiado fácil de adivinar. Incluya más variedad de caracteres para hacerlo más complejo.
patient\ id\ not\ found\ response = Enviar el siguiente mensaje de respuesta, sí las validaciones pasan correctamente pero no se encontró el Medic ID.
Expand Down Expand Up @@ -1272,6 +1280,7 @@ translation.add = Agregar Traducción
translation.key = Clave de traducción
unique.id = Identificación única
unknown.contact = Contacto desconocido
update.password.help = El usuario deberá restablecer su contraseña en su próximo inicio de sesión
upgrade = Actualizar
upgrade.description = Para actualizar su aplicación a una versión, beta o rama específica, se recomienda realizar primero un respaldo. Esto permite realizar un trabajo en segundo plano para preparar la instalación sin interrumpir a los usuarios. Una vez que se complete el respaldo, haga click en Instalar para continuar con la actualización. Esta acción no se puede deshacer, así que asegúrese de que se haya respaldado sus datos y de que se hayan notificado a sus usuarios sobre un posible tiempo de inactividad en el sistema.
upload = Subir
Expand Down
9 changes: 9 additions & 0 deletions api/resources/translations/messages-fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ bulkdelete.confirm.title = Supprimer l'enregistrement?
bulkdelete.confirm.title.plural = Supprimer les enregistrements sélectionnés?
call = Appeler
case_id = ID du cas
change.password.confirm.password = Confirmer le mot de passe
change.password.hint = Utilisez une combinaison de lettres majuscules, de chiffres et de caractères spéciaux.
change.password.new.password = Nouveau mot de passe
change.password.submit = Changer le mot de passe
change.password.title = Changez votre mot de passe
child_birth_date = Date de naissance de l'enfant
child_birth_outcome = Résultat de la naissance de l'enfant
child_birth_weight = Poids de l'enfant à la naissance
Expand Down Expand Up @@ -964,8 +969,11 @@ partner.logo.upload = Télécharger le logo du partenaire
partner.name.field = Nom du partenaire
partner.supporting = Partenaires de soutien
partner.tab.partners = Partenaires
password.current.incorrect = Le mot de passe actuel n'est pas correct
password.incorrect = Mot de passe incorrect
password.length.minimum = Le mot de passe doit être au moins {{minimum}} caractères.
password.must.match = Le mot de passe et la confirmation du mot de passe doivent correspondre
password.same = Le nouveau mot de passe doit être différent du mot de passe actuel
password.update = Mettre à jour mot de passe
password.weak = Le mot de passe est trop facile à deviner. Inclure au moins une lettre majuscule, un chiffre et un caractère spécial.
patient\ id\ not\ found\ response = Envoyer cette réponse si les validations passent, mais l'ID du patient n'est pas retrouvé.
Expand Down Expand Up @@ -1272,6 +1280,7 @@ translation.add = Ajouter une traduction
translation.key = Clé de traduction
unique.id = ID unique
unknown.contact = Contact inconnu
update.password.help = L'utilisateur devra réinitialiser son mot de passe lors de sa prochaine connexion
upgrade = Mise à jour
upgrade.description = Pour mettre à jour votre application vers une version, une version bêta ou une branche spécifique, il est recommandé d'effectuer d'abord une étape. Cela permet d'effectuer un travail en arrière-plan pour préparer l'installation sans interrompre les utilisateurs. Une fois la préparation terminée, cliquez sur Installer pour procéder à la mise à jour. Cette action ne peut pas être annulée, veuillez donc vous assurer que vos données ont été sauvegardées et que vos utilisateurs sont informés des temps d'arrêt.
upload = Télécharger
Expand Down
8 changes: 8 additions & 0 deletions api/resources/translations/messages-id.properties
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ bulkdelete.confirm.title = Hapus pencatatan?
bulkdelete.confirm.title.plural = Hapus pencatatan yang dipilih?
call = Telepon
case_id = ID Kasus
change.password.confirm.password = Konfirmasikan kata sandi
change.password.hint = Gunakan huruf besar, angka, dan karakter khusus.
change.password.new.password = Kata sandi baru
change.password.submit = Ubah kata sandi
change.password.title = Ubah kata sandi Anda
child_birth_date = Tanggal Lahir Anak
child_birth_outcome = Outcome Anak dilahirkan
child_birth_weight = Berat Lahir Anak
Expand Down Expand Up @@ -884,8 +889,11 @@ partner.logo.upload =
partner.name.field =
partner.supporting =
partner.tab.partners =
password.current.incorrect = Kata sandi saat ini salah
password.incorrect = Kata sandi tidak benar.
password.length.minimum = Kata sandi harus setidaknya {{minimum}} karakter.
password.must.match = Kata sandi dan konfirmasi kata sandi harus cocok
password.same = Kata sandi baru harus berbeda dengan kata sandi saat ini
password.update = Perbaharui Kata Sandi
password.weak = Kata sandinya terlalu mudah. Sertakan setidaknya 1 huruf besar, 1 angka, dan 1 karakter khusus.
patient\ id\ not\ found\ response = Kirim pesan respon ini bila lolos validasi tetapi Medic ID tidak ditemukan
Expand Down
9 changes: 9 additions & 0 deletions api/resources/translations/messages-ne.properties
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ bulkdelete.confirm.title = रेकर्ड मेटाउने हो?
bulkdelete.confirm.title.plural = चयन गरिएका रेकर्डहरू मेट्ने हो?
call = कल
case_id = केस आईडी
change.password.confirm.password = पासवर्ड पुष्टि गर्नुहोस्
change.password.hint = ठूला अक्षर, अङ्क र चिन्हहरूको मिश्रण भएको एउटा भरपर्दो पासवर्ड सिर्जना गर्नुहोस्
change.password.new.password = नयाँ पासवर्ड
change.password.submit = पासवर्ड परिवर्तन गर्नुहोस्
change.password.title = आफ्नो पासवर्ड परिवर्तन गर्नुहोस्
child_birth_date = बच्चाको जन्म मिति
child_birth_outcome = बच्चाको जन्मावस्था
child_birth_weight = बच्चाको जन्म तौल
Expand Down Expand Up @@ -964,8 +969,11 @@ partner.logo.upload = पार्टनर लोगो अपलोड गर
partner.name.field = पार्टनरको नाम
partner.supporting = सहयोगी पार्टनरहरू
partner.tab.partners = पार्टनरहरू
password.current.incorrect = वर्तमान पासवर्ड गलत छ
password.incorrect = पासवर्ड मिलेन।
password.length.minimum = पासवर्ड कम्तीमा {{minimum}} अक्षरको हुनुपर्छ।
password.must.match = तपाईंले पासवर्ड हाल्नुहोस् र पासवर्ड पुष्टि गर्नुहोस् नामक फिल्डमा हाल्नुभएको पासवर्ड एउटै छैन। फेरि प्रयास गर्नुहोस्।
password.same = नयाँ पासवर्ड वर्तमान पासवर्ड भन्दा फरक हुनुपर्छ
password.update = अपडेट पासवर्ड
password.weak = यो पासवर्ड कमजोर छ।
patient\ id\ not\ found\ response = बिरामिको आईडी नपाइएमा पठाइने सन्देश
Expand Down Expand Up @@ -1272,6 +1280,7 @@ translation.add = नयाँ अनुवाद कुञ्जी थप्
translation.key = अनुवाद कुञ्जी
unique.id = आईडी
unknown.contact = अपरिचित सम्पर्क
update.password.help = यो प्रयोगकर्ताले अर्को पटक लगइन गर्दा आफ्नो पासवर्ड पुन: सेट गर्नुपर्नेछ।
upgrade = अपग्रेड
upgrade.description = तपाईँको एपलाई कुनै रिलीज, बीटा, वा ब्रान्चमा अपग्रेड गर्न, पहिलो चरणको रूपमा स्टेज गर्न सिफारिस गरिन्छ। यसले प्रयोगकर्ताहरूलाई अवरोध नगरी पृष्ठभूमिमा इन्स्टलेसन तयारी गर्छ। स्टेजिंग पुरा भएपछि, अपग्रेडको लागि 'इन्स्टल गर्नुहोस्' क्लिक गर्नुहोस्। यो पछि, यसलाई पहिलाकै अवस्थामा लैजान सकिँदैन, त्यसैले कृपया तपाईँको डेटा ब्याकअप गरिएको छ र तपाईँका प्रयोगकर्ताहरूलाई सेवा अवरुद्ध रहने बारे जानकारी दिइएको छ भन्ने निश्चित गर्नुहोस्।
upload = अपलोड
Expand Down
11 changes: 10 additions & 1 deletion api/resources/translations/messages-sw.properties
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ bulkdelete.confirm.title = Futa rekodi?
bulkdelete.confirm.title.plural = Ungependa kufuta rekodi ulizochagua?
call = Piga simu
case_id = Kitambulisho cha kesi
change.password.confirm.password = Thibitisha nenosiri
change.password.hint = Tumia herufi kubwa, nambari na herufi maalum.
change.password.new.password = Nenosiri mpya
change.password.submit = Badilisha nenosiri
change.password.title = Badilisha nenosiri lako
child_birth_date = Tarehe ya kuzaliwa mtoto
child_birth_outcome = Matokeo ya mtoto mzaliwa
child_birth_weight = Uzani wa mtoto mzaliwa
Expand Down Expand Up @@ -964,8 +969,11 @@ partner.logo.upload = Pakia nembo ya mshirika
partner.name.field = Jina la mshirika
partner.supporting = Washirika wanaounga mkono
partner.tab.partners = Washirika
password.current.incorrect = Nenosiri la sasa si sahihi
password.incorrect = Nenosiri si sahihi
password.length.minimum = Nenosiri inapaswa kuwa na wahusika {{minimum}} kwenda juu
password.must.match = Nenosiri na uthibitisho wa nenosiri lazima zilingane
password.same = Nenosiri mpya lazima liwe tofauti na nenosiri la sasa
password.update = Badilisha nenosiri
password.weak = Nywila ni rahisi sana nadhani. Jumuisha anuwai ya herufi ili kuifanya iwe ngumu zaidi.
patient\ id\ not\ found\ response = Tuma ujumbe wa majibu ufuatao kama validations zimepitishwa lakini ID ya mgonjwa haiko
Expand Down Expand Up @@ -1271,7 +1279,8 @@ training_materials.page.title = Vifaa vya mafunzo
translation.add = Ongeza tafsiri
translation.key = Ufunguo wa tafsiri
unique.id = Kitambulisho cha kipekee
unknown.contact = Mtu asiyejulikana
unknown.contact = Mtu asiyejulikana
update.password.help = Mtumiaji atahitajika kuweka upya nenosiri lake wakati wa kuingia ujayo
upgrade = Boresha
upgrade.description = Ili kupata toleo jipya la programu yako, inashauriwa uweke jukwaani kwanza. Hii inaruhusu kazi ya chinichini kufanywa ili kuandaa usakinishaji bila kukatiza watumiaji. Mara tu uwekaji jukwaa utakapokamilika, bofya Sakinisha ili kuendelea na uboreshaji. Kitendo hiki hakiwezi kutenduliwa, kwa hivyo tafadhali hakikisha kwamba data yako imechelezwa na watumiaji wako wanaarifiwa kuhusu muda wa hitilafu.
upload = Pakia
Expand Down
Loading

0 comments on commit 67b5330

Please sign in to comment.