-
Notifications
You must be signed in to change notification settings - Fork 931
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Add API support for enabling and disabling the picture login facility setting, implementing a bulk update endpoint for assigning picture passcodes to learners, and assigning passcodes to new learners created while the setting is active.
Complexity: Medium
Target branch: develop
Context
Once picture_password field added to FacilityUser, the API layer needs to be wired up. The learner_can_login_with_picture_password boolean on FacilityDataset is the source of truth for whether picture login is enabled for a facility.
The Change
1. API: Bulk Assignment/Un-assignment on Setting Change (kolibri/core/auth/api.py)
- Update FacilityDatasetViewSet with a new bulk update endpoint that sets
learner_can_login_with_picture_passwordtoTruefor a facility and:- Calls
assign_picture_password()for all existing learners in the facility wherepicture_password=None. - Sets
learner_can_edit_passwordto False. - Sets the password for all existing learners in the facility as
NOT_SPECIFIEDto allow username only sign-in. - If a facility has more than 1300 learners, reject attempts to enable
learner_can_login_with_picture_passwordwith a clear error response.
- Calls
- Add a method to
kolibri/plugins/facility/frontend/modules/facilityConfig/actions.jsthat will call the FacilityDatasetViewSet action from above. This new action will need to be exported inkolibri/plugins/facility/frontend/modules/facilityConfig/index.jsas well, so that they can be called in the frontend.
2. Assignment on New Learner Creation (kolibri/core/auth/models.py)
- When a new learner is created in a facility where
learner_can_login_with_picture_passwordisTrueand the learner count is still at or below 1300, automatically callassign_picture_password()on user creation. If the learner count is >= 1300, thepicture_passcodeshould not be assigned. The appropriate hook for this is inBaseFacilityUserModelManager.create_user.
Out of Scope
- Picture passcode sequence availability check and creation
Acceptance Criteria
General
- Facility Settings API endpoint reads and writes to
learner_can_login_with_picture_password
onFacilityDatasetas the source of truth for whether picture login is enabled - Enabling picture login for a facility triggers bulk assignment for all
learners withpicture_password=Noneand does not overwrite sequences already assigned to learners - Attempting to enable picture login for a facility with >1300 learners returns an
appropriate error response - New learner creation in a facility with picture login enabled results in
picture_passwordandpasswordbeing automatically assigned - Coach and admin users are never assigned a
picture_password
Testing
- Unit test: enabling picture login is rejected for facilities with >=1300 learners
- Unit test: bulk assignment skips learners who already have a
picture_passwordset - Unit test: new learner creation in a picture-login-enabled facility results in a passcode being assigned
- Unit test: coach and admin users are never assigned a
picture_password
References
- Existing pattern:
learner_can_login_with_no_passwordonFacilityDataset kolibri/core/auth/api.py-
kolibri/core/auth/serializers.py
BaseFacilityUserModelManager.create_user
AI usage
🤖 This issue was written with AI assistance, under supervision, review and final edits by [@LianaHarris360 ] 🤖
