You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/10/06 13:41:36 UTC

[airavata-django-portal] 12/13: AIRAVATA-3468 Create user profile if it doesn't exist

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch AIRAVATA-3319-handle-missing-name-and-email-attributes-from-cilo
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 5d765ac7cba7ec5b973640821b1b2b87adc16ab9
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Aug 2 10:01:54 2021 -0400

    AIRAVATA-3468 Create user profile if it doesn't exist
---
 django_airavata/apps/auth/serializers.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/django_airavata/apps/auth/serializers.py b/django_airavata/apps/auth/serializers.py
index 40723fd..29e2ef9 100644
--- a/django_airavata/apps/auth/serializers.py
+++ b/django_airavata/apps/auth/serializers.py
@@ -56,6 +56,12 @@ class UserSerializer(serializers.ModelSerializer):
         instance.save()
         # save in the user profile service too
         user_profile_client = request.profile_service['user_profile']
+        # Check if user profile exists and create it if not first. User Profile
+        # doesn't get created until the profile is complete, so it may not exist yet.
+        if not user_profile_client.doesUserExist(request.authz_token,
+                                                 request.user.username,
+                                                 settings.GATEWAY_ID):
+            user_profile_client.initializeUserProfile(request.authz_token)
         airavata_user_profile = user_profile_client.getUserProfileById(
             request.authz_token, request.user.username, settings.GATEWAY_ID)
         airavata_user_profile.firstName = instance.first_name