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 2019/06/20 15:21:07 UTC
[airavata-django-portal] 03/06: AIRAVATA-3080 Allow admin to
manually enable user
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
commit 972ca02ac466e72a18369fb3d16ecdd1a8eb296f
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Sun Jun 16 18:49:51 2019 -0400
AIRAVATA-3080 Allow admin to manually enable user
---
.../src/components/users/EnableUserPanel.vue | 31 ++++++++++++
.../IdentityServiceUserManagementContainer.vue | 20 ++++----
.../UnverifiedEmailUserManagementContainer.vue | 55 +++++++++++++++++++---
.../src/components/users/UserDetailsContainer.vue | 25 +++++++---
.../django_airavata_api/js/service_config.js | 7 +++
django_airavata/apps/api/views.py | 8 ++++
6 files changed, 124 insertions(+), 22 deletions(-)
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/EnableUserPanel.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/EnableUserPanel.vue
new file mode 100644
index 0000000..a81ef82
--- /dev/null
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/EnableUserPanel.vue
@@ -0,0 +1,31 @@
+<template>
+ <b-card header="Enable User">
+ <p class="card-text">
+ Enable user {{ username }} to log in. By clicking <b>Enable</b> you are verifying that the user's email address
+ is {{ email }}
+ </p>
+ <b-button @click="enable">Enable</b-button>
+ </b-card>
+</template>
+
+<script>
+export default {
+ name: "enable-user-panel",
+ props: {
+ username: {
+ type: String,
+ required: true
+ },
+ email: {
+ type: String,
+ required: true
+ }
+ },
+ methods: {
+ enable() {
+ this.$emit("enable-user", this.username);
+ }
+ }
+};
+</script>
+
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/IdentityServiceUserManagementContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/IdentityServiceUserManagementContainer.vue
index dba6213..1a40b3f 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/IdentityServiceUserManagementContainer.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/IdentityServiceUserManagementContainer.vue
@@ -33,18 +33,16 @@
>
<template
slot="creationTime"
- slot-scope="data">
- <human-date :date="data.value"/>
+ slot-scope="data"
+ >
+ <human-date :date="data.value" />
</template>
<template
slot="action"
slot-scope="data"
>
- <b-button
- v-if="data.item.airavataUserProfileExists"
- @click="toggleDetails(data)"
- >
- Edit Groups
+ <b-button @click="toggleDetails(data)">
+ Edit
</b-button>
</template>
<template
@@ -55,6 +53,7 @@
:iam-user-profile="data.item"
:editable-groups="editableGroups"
@groups-updated="groupsUpdated"
+ @enable-user="enableUser"
/>
</template>
</b-table>
@@ -87,7 +86,7 @@ export default {
},
components: {
pager: components.Pager,
- 'human-date': components.HumanDate,
+ "human-date": components.HumanDate,
UserDetailsContainer
},
created() {
@@ -195,6 +194,11 @@ export default {
this.usersPaginator = null;
this.search = null;
this.reloadUserProfiles();
+ },
+ enableUser(username) {
+ services.IAMUserProfileService.enable({ lookup: username }).finally(() =>
+ this.reloadUserProfiles()
+ );
}
}
};
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 5cb7edd..8c71046 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
@@ -11,8 +11,28 @@
>
<template
slot="creationTime"
- slot-scope="data">
- <human-date :date="data.value"/>
+ slot-scope="data"
+ >
+ <human-date :date="data.value" />
+ </template>
+ <template
+ slot="action"
+ slot-scope="data"
+ >
+ <b-button @click="toggleDetails(data)">
+ Edit
+ </b-button>
+ </template>
+ <template
+ slot="row-details"
+ slot-scope="data"
+ >
+ <enable-user-panel
+ v-if="!data.item.enabled && !data.item.emailVerified"
+ :username="data.item.userId"
+ :email="data.item.email"
+ @enable-user="enableUser"
+ />
</template>
</b-table>
<pager
@@ -29,16 +49,20 @@
<script>
import { components } from "django-airavata-common-ui";
import { services } from "django-airavata-api";
+import EnableUserPanel from "./EnableUserPanel";
+
export default {
name: "unverified-email-user-management-container",
data() {
return {
usersPaginator: null,
+ showingDetails: {}
};
},
components: {
pager: components.Pager,
- 'human-date': components.HumanDate,
+ "human-date": components.HumanDate,
+ EnableUserPanel
},
created() {
services.UnverifiedEmailUserProfileService.list({ limit: 10 }).then(
@@ -72,13 +96,15 @@ export default {
label: "Created",
key: "creationTime"
},
+ {
+ label: "Action",
+ key: "action"
+ }
];
},
items() {
- return this.usersPaginator
- ? this.usersPaginator.results
- : [];
- },
+ return this.usersPaginator ? this.usersPaginator.results : [];
+ }
},
methods: {
next() {
@@ -87,6 +113,21 @@ export default {
previous() {
this.usersPaginator.previous();
},
+ enableUser(username) {
+ services.IAMUserProfileService.enable({ lookup: username }).finally(() =>
+ this.loadUnverifiedEmailUsers()
+ );
+ },
+ loadUnverifiedEmailUsers() {
+ return services.UnverifiedEmailUserProfileService.list({
+ limit: 10
+ }).then(users => (this.usersPaginator = users));
+ },
+ toggleDetails(row) {
+ row.toggleDetails();
+ this.showingDetails[row.item.userId] = !this
+ .showingDetails[row.item.userId];
+ },
}
};
</script>
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UserDetailsContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UserDetailsContainer.vue
index 18ce57f..8bd6bd8 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UserDetailsContainer.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/users/UserDetailsContainer.vue
@@ -1,14 +1,24 @@
<template>
- <user-group-membership-editor
- v-model="localIAMUserProfile.groups"
- :editable-groups="editableGroups"
- :airavata-internal-user-id="iamUserProfile.airavataInternalUserId"
- @input="groupsUpdated"
- />
+ <div>
+ <user-group-membership-editor
+ v-if="iamUserProfile.airavataUserProfileExists"
+ v-model="localIAMUserProfile.groups"
+ :editable-groups="editableGroups"
+ :airavata-internal-user-id="iamUserProfile.airavataInternalUserId"
+ @input="groupsUpdated"
+ />
+ <enable-user-panel
+ v-if="!iamUserProfile.enabled && !iamUserProfile.emailVerified"
+ :username="iamUserProfile.userId"
+ :email="iamUserProfile.email"
+ @enable-user="$emit('enable-user', $event)"
+ />
+ </div>
</template>
<script>
import { models } from "django-airavata-api";
import UserGroupMembershipEditor from "./UserGroupMembershipEditor";
+import EnableUserPanel from "./EnableUserPanel";
export default {
name: "user-details-container",
@@ -23,7 +33,8 @@ export default {
}
},
components: {
- UserGroupMembershipEditor
+ UserGroupMembershipEditor,
+ EnableUserPanel
},
data() {
return {
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
index ed76e06..473305e 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
@@ -244,6 +244,13 @@ export default {
url: "/api/iam-user-profiles",
viewSet: true,
pagination: true,
+ methods: {
+ enable: {
+ url: "/api/iam-user-profiles/<lookup>/enable/",
+ requestType: "post",
+ modelClass: IAMUserProfile
+ }
+ },
queryParams: ["limit", "offset", "search"],
modelClass: IAMUserProfile
},
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index f22a4ea..d3a1db3 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1422,6 +1422,14 @@ class IAMUserViewSet(mixins.CreateModelMixin,
group_manager_client.removeUsersFromGroup(
self.authz_token, [user_id], group_id)
+ @detail_route(methods=['post'])
+ def enable(self, request, user_id=None):
+ iam_admin_client.enable_user(user_id)
+ instance = self.get_instance(user_id)
+ serializer = self.serializer_class(instance=instance,
+ context={'request': request})
+ return Response(serializer.data)
+
def _convert_user_profile(self, user_profile):
user_profile_client = self.request.profile_service['user_profile']
group_manager_client = self.request.profile_service['group_manager']