From f28ecca49851497d6f360daa4237547b557c993c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 23 Jun 2020 19:25:56 +0200 Subject: [PATCH] Fix android user creation during init Init was crashing with error: django.db.utils.IntegrityError: (1062, "Duplicate entry 'android' for key 'client_id'") See https://discuss.overhang.io/t/reset-password-email-sent-but-activation-email-dont/690/4 --- CHANGELOG.md | 1 + tutor/templates/hooks/lms/init | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8de49e28e..e169d20b0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Bugfix] Fix android user creation during init - [Bugfix] Fix undefined settings in k8s scripts, such as `createuser` ## v10.0.7 (2020-06-22) diff --git a/tutor/templates/hooks/lms/init b/tutor/templates/hooks/lms/init index c91a2139b0..f7db997931 100644 --- a/tutor/templates/hooks/lms/init +++ b/tutor/templates/hooks/lms/init @@ -4,12 +4,16 @@ echo "Loading settings $DJANGO_SETTINGS_MODULE" ./manage.py lms migrate +# Delete obsolete credentials for Android application +./manage.py lms shell -c 'from oauth2_provider.models import get_application_model +get_application_model().objects.filter(name="android").exclude(user__username="login_service_user").delete()' # Create oauth credentials for Android application ./manage.py lms create_dot_application \ --client-id android \ --client-secret {{ ANDROID_OAUTH2_SECRET }} \ --grant-type password \ --public \ + --update \ android \ login_service_user