This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/master by this push:
new 2f82855 AIRAVATA-3166 Check that user exists before fetching from IAM
service
2f82855 is described below
commit 2f828557790a9b356b6520c88ccd399b91954bb7
Author: Marcus Christie <[email protected]>
AuthorDate: Tue Jul 23 14:56:05 2019 -0400
AIRAVATA-3166 Check that user exists before fetching from IAM service
---
.../UnverifiedEmailUserManagementContainer.vue | 4 +-
django_airavata/apps/api/views.py | 44 ++++++++++++----------
2 files changed, 28 insertions(+), 20 deletions(-)
diff --git
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UnverifiedEmailUserManagementContainer.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UnverifiedEmailUserManagementContainer.vue
index 8b066ff..606346e 100644
---
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UnverifiedEmailUserManagementContainer.vue
+++
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UnverifiedEmailUserManagementContainer.vue
@@ -55,6 +55,7 @@
import { components } from "django-airavata-common-ui";
import { services } from "django-airavata-api";
import EnableUserPanel from "./EnableUserPanel";
+import DeleteUserPanel from "./DeleteUserPanel";
export default {
name: "unverified-email-user-management-container",
@@ -67,7 +68,8 @@ export default {
components: {
pager: components.Pager,
"human-date": components.HumanDate,
- EnableUserPanel
+ EnableUserPanel,
+ DeleteUserPanel
},
created() {
services.UnverifiedEmailUserProfileService.list({ limit: 10 }).then(
diff --git a/django_airavata/apps/api/views.py
b/django_airavata/apps/api/views.py
index e09e20b..a693253 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1655,26 +1655,32 @@ class UnverifiedEmailUserViewSet(mixins.ListModelMixin,
unverified_emails = unverified_emails[offset:offset + limit]
results = []
for unverified_email in unverified_emails:
- username = unverified_email['username']
- user_profile = iam_admin_client.get_user(username)
- if (user_profile.State == Status.CONFIRMED or
- user_profile.State == Status.ACTIVE):
- # TODO: test this
+ unverified_username = unverified_email['username']
+ if iam_admin_client.is_user_exist(unverified_username):
+ user_profile = iam_admin_client.get_user(unverified_username)
+ if (user_profile.State == Status.CONFIRMED or
+ user_profile.State == Status.ACTIVE):
+ # TODO: test this
+ EmailVerification.objects.filter(
+ username=unverified_username).update(
+ verified=True)
+ continue
+ results.append({
+ 'userId': user_profile.userId,
+ 'gatewayId': user_profile.gatewayId,
+ 'email': user_profile.emails[0],
+ 'firstName': user_profile.firstName,
+ 'lastName': user_profile.lastName,
+ 'enabled': user_profile.State == Status.ACTIVE,
+ 'emailVerified': (user_profile.State == Status.CONFIRMED or
+ user_profile.State == Status.ACTIVE),
+ 'creationTime': user_profile.creationTime,
+ })
+ else:
+ # Delete the EmailVerification records since that user no
+ # longer exists in the IAM service
EmailVerification.objects.filter(
- username=username).update(
- verified=True)
- continue
- results.append({
- 'userId': user_profile.userId,
- 'gatewayId': user_profile.gatewayId,
- 'email': user_profile.emails[0],
- 'firstName': user_profile.firstName,
- 'lastName': user_profile.lastName,
- 'enabled': user_profile.State == Status.ACTIVE,
- 'emailVerified': (user_profile.State == Status.CONFIRMED or
- user_profile.State == Status.ACTIVE),
- 'creationTime': user_profile.creationTime,
- })
+ username=unverified_username).delete()
return results