-
Notifications
You must be signed in to change notification settings - Fork 818
Use token generator to authenticate just provisioned facility superadmin #13732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use token generator to authenticate just provisioned facility superadmin #13732
Conversation
Build Artifacts
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all makes sense to me - one possible bit of even further cleanup!
| username = request.data.get("username", "") | ||
| password = request.data.get("password", "") | ||
| facility_id = request.data.get("facility", None) | ||
| def validate(self, attrs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't even thinking that we could move so much of the viewset logic into the validate method, but this is a really nice separation of concerns, and provides such a neat interface between the serializer and the viewset, where the viewset only has to worry about the user and nothing else!
|
|
||
| from .utils import TokenGenerator | ||
| from kolibri.core.auth.models import FacilityUser | ||
| from kolibri.core.utils.token_generator import TokenGenerator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only other thought here is, could we actually delete the MergedUserLoginViewset, and just update the frontend in the user merging workflow to use your new enhanced SessionViewset instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll file a follow up issue for this to look at on develop as cleanup!
2e1ffaf to
6601958
Compare
6601958 to
201eefa
Compare
|
This is good to go and ready for manual QA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AlexVelezLl - LGTM, no regressions observed while manually testing.
601f202
into
learningequality:release-v0.18.x
Summary
Imported users using the admin account in the setup wizard plugin were not being able to login after the device was provisioned because the frontend didn't have their password, so the
loginmethod was failing. To prevent this, we now use theTokenGeneratorclass to generate a temporary token to authenticate the superadmin user just after the device was provisioned.provisiondevicetask to generate the auth token once the provision was completed.SessionViewSet'screatemethod to validate theauth_tokengenerated on the deviceprovision task.SessionViewSet'screatemethod was refactored to use a serializer to get validate its params and get the user is being authenticated, and improve the readibility of the code.TokenGeneratorclass fromkolibri/plugins/user_profile/utils.pytokolibri/core/utils/token_generator.pyso we can access it in the setup wizard plugin too.provisiondevicetask error handling.References
Closes #13715.
Reviewer guidance