add validations and groups admin role based auth
diff --git a/custos-demo-gateway/.env b/custos-demo-gateway/.env
index 62b824d..69e2f42 100644
--- a/custos-demo-gateway/.env
+++ b/custos-demo-gateway/.env
@@ -1,3 +1,3 @@
-VUE_APP_CLIENT_ID=""
-VUE_APP_CLIENT_SEC=""
+VUE_APP_CLIENT_ID="tenant Id"
+VUE_APP_CLIENT_SEC="tenant sec"
VUE_APP_REDIRECT_URI="http://localhost:8080/callback"
diff --git a/custos-demo-gateway/.idea/workspace.xml b/custos-demo-gateway/.idea/workspace.xml
index a25371f..14a256e 100644
--- a/custos-demo-gateway/.idea/workspace.xml
+++ b/custos-demo-gateway/.idea/workspace.xml
@@ -98,7 +98,8 @@
<option name="presentableId" value="Default" />
<updated>1599486133223</updated>
<workItem from="1599486134588" duration="217546000" />
- <workItem from="1601038400517" duration="67230000" />
+ <workItem from="1601038400517" duration="67420000" />
+ <workItem from="1602211298031" duration="8699000" />
</task>
<servers />
</component>
diff --git a/custos-demo-gateway/Dockerfile b/custos-demo-gateway/Dockerfile
index 1dc7bab..079efea 100644
--- a/custos-demo-gateway/Dockerfile
+++ b/custos-demo-gateway/Dockerfile
@@ -14,6 +14,6 @@
COPY fullchain.pem /etc/nginx/fullchain.pem
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
-EXPOSE 8080
+EXPOSE 8080 443
ENTRYPOINT [ "/entrypoint.sh" ]
#CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
diff --git a/custos-demo-gateway/docker-compose.yml b/custos-demo-gateway/docker-compose.yml
index f65426b..400ec05 100644
--- a/custos-demo-gateway/docker-compose.yml
+++ b/custos-demo-gateway/docker-compose.yml
@@ -5,7 +5,7 @@
ports:
- "8080:8080"
environment:
- VUE_APP_CLIENT_ID: ''
- VUE_APP_CLIENT_SEC: ''
+ VUE_APP_CLIENT_ID: 'tenant-id'
+ VUE_APP_CLIENT_SEC: 'tenant-sec'
VUE_APP_REDIRECT_URI: 'http://localhost:8080/callback'
VUE_APP_CUSTOS_TOKEN_ENDPOINT: 'https://custos.scigap.org/apiserver/identity-management/v1.0.0/token'
diff --git a/custos-demo-gateway/src/components/registration/CreateAccount.vue b/custos-demo-gateway/src/components/registration/CreateAccount.vue
index b5d8fb0..ea644cb 100644
--- a/custos-demo-gateway/src/components/registration/CreateAccount.vue
+++ b/custos-demo-gateway/src/components/registration/CreateAccount.vue
@@ -165,12 +165,12 @@
this.isButtonDisabled = false
}
- if (this.firstName == null || this.firstName == '') {
+ if (this.firstName == null || this.firstName == '' || this.firstName.length>20) {
this.firstNameError = true
this.isButtonDisabled = false
}
- if (this.lastName == null || this.lastName == '') {
+ if (this.lastName == null || this.lastName == '' || this.lastName.length>20) {
this.lastnameError = true
this.isButtonDisabled = false
}
diff --git a/custos-demo-gateway/src/components/workspace/Groups.vue b/custos-demo-gateway/src/components/workspace/Groups.vue
index 138c969..e7953f2 100644
--- a/custos-demo-gateway/src/components/workspace/Groups.vue
+++ b/custos-demo-gateway/src/components/workspace/Groups.vue
@@ -54,7 +54,7 @@
</div>
<div class="w-100">
- <b-button class="addmemberbtn" variant="outline-primary" v-on:click="addMemberShip">Add Member
+ <b-button class="addmemberbtn" variant="outline-primary" :disabled="disableAccess" v-on:click="addMemberShip">Add Member
</b-button>
</div>
<div class="groupformItem">
@@ -65,7 +65,7 @@
</b-table>
</div>
<div class="w-100">
- <b-button class="addmemberbtn" variant="outline-primary" v-on:click="addChildGroup">Add Child
+ <b-button class="addmemberbtn" variant="outline-primary" :disabled="disableAccess" v-on:click="addChildGroup">Add Child
Group
</b-button>
</div>
@@ -78,6 +78,7 @@
size="sm"
class="grBtnDel"
v-on:click="removeGroupProfile"
+ :disabled="disableAccess"
@click="show=false"
>
Delete
@@ -97,6 +98,7 @@
size="sm"
class="grBtnUp"
v-on:click="updateGroupProfile"
+ :disabled="disableAccess"
@click="show=false"
>
@@ -278,7 +280,8 @@
groupsLoading: false,
operationCompleted: true,
currentUser: null,
- groupError: null
+ groupError: null,
+ disableAccess: false
}
},
@@ -309,6 +312,25 @@
let response = await this.$store.dispatch('group/getAllChildGroups', data)
this.childGroupMembers = response.groups
+ if (!this.isAdminUser && this.selectedOwnerId != this.currentUser) {
+
+ let data = {
+ client_id: this.custosId,
+ client_sec: this.custosSec,
+ groupId: this.selectedId,
+ username: this.currentUser,
+ type: 'ADMIN'
+ }
+
+ let resp = await this.$store.dispatch('group/hasAccess', data)
+
+ if (!resp.status) {
+ this.disableAccess = true
+
+ }
+
+ }
+
this.$refs.groupmodel.show()
}
},
diff --git a/custos-demo-gateway/src/components/workspace/Profile.vue b/custos-demo-gateway/src/components/workspace/Profile.vue
index aff17ac..31162b3 100644
--- a/custos-demo-gateway/src/components/workspace/Profile.vue
+++ b/custos-demo-gateway/src/components/workspace/Profile.vue
@@ -6,7 +6,7 @@
<div class="row">
<div class="column">
- <div v-if="!this.updatingProfile" class="d-flex justify-content-center mb-3">
+ <div v-if="this.updatingProfile" class="d-flex justify-content-center mb-3">
<b-spinner variant="primary" label="Text Centered"></b-spinner>
</div>
<div class="profile">
@@ -31,6 +31,12 @@
<div class="profItem">
<p>First Name</p>
+ <div>
+ <b-alert v-model="firstNameError" variant="danger" dismissible
+ @dismissed="this.callDismissed">
+ Invalid name
+ </b-alert>
+ </div>
<b-form-input
id="input-2"
v-model="first_name"
@@ -40,6 +46,12 @@
<div class="profItem">
<p>Last Name</p>
+ <div>
+ <b-alert v-model="lastnameError" variant="danger" dismissible
+ @dismissed="this.callDismissed">
+ Invalid name
+ </b-alert>
+ </div>
<b-form-input
id="input-3"
v-model="last_name"
@@ -49,6 +61,12 @@
<div class="profItem">
<p>Email</p>
+ <div>
+ <b-alert v-model="emailError" variant="danger" dismissible
+ @dismissed="this.callDismissed">
+ Invalid email
+ </b-alert>
+ </div>
<b-form-input
id="input-3"
v-model="email"
@@ -140,7 +158,10 @@
selectedKey: null,
selectedValue: null,
operationCompleted: true,
- updatingProfile: true
+ updatingProfile: false,
+ emailError: false,
+ firstNameError: false,
+ lastnameError: false
}
},
@@ -210,25 +231,56 @@
},
async updateProfile() {
- this.updatingProfile = false
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
- username: this.currentUserName,
- first_name: this.first_name,
- last_name: this.last_name,
- email: this.email
- }
- }
- await this.$store.dispatch('user/updateUserProfile', data)
this.updatingProfile = true
+
+ // eslint-disable-next-line no-useless-escape
+ let emailRegs = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i
+ let regexPucn = /[~!" "@#$%^&*()+=;"'<>,.]/
+
+ if (this.first_name == null || this.first_name =='' || regexPucn.test(this.first_name) || this.first_name.length>20){
+ this.firstNameError =true
+ this.updatingProfile = false
+ }
+
+ if (this.last_name == null || this.last_name =='' || regexPucn.test(this.last_name) || this.last_name.length >20){
+ this.lastnameError =true
+ this.updatingProfile = false
+ }
+
+
+ if (this.email == null || emailRegs.test(this.email) == false ){
+ this.emailError =true
+ this.updatingProfile = false
+ }
+
+ if (!(this.firstNameError || this.lastnameError || this.emailError)) {
+
+ let data = {
+ client_id: this.custosId,
+ client_sec: this.custosSec,
+ body: {
+ username: this.currentUserName,
+ first_name: this.first_name,
+ last_name: this.last_name,
+ email: this.email
+ }
+ }
+ await this.$store.dispatch('user/updateUserProfile', data)
+ this.updatingProfile = false
+ }
},
async goToWorkspace() {
await this.$router.push('/workspace')
},
+ async callDismissed() {
+ this.emailError = false
+ this.firstNameError = false
+ this.lastnameError = false
+ }
+
+
},
async mounted() {
diff --git a/custos-demo-gateway/src/components/workspace/Secrets.vue b/custos-demo-gateway/src/components/workspace/Secrets.vue
index 9864c17..b0406fe 100644
--- a/custos-demo-gateway/src/components/workspace/Secrets.vue
+++ b/custos-demo-gateway/src/components/workspace/Secrets.vue
@@ -104,7 +104,8 @@
selectedExPrivKey: null,
selectedExOwnerId: null,
currentUserName: null,
- secretsLoading: false
+ secretsLoading: false,
+ passwordEmptyError: false
}
},
@@ -180,37 +181,44 @@
await this.$store.dispatch('sharing/createEntity', dataEn)
} else {
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
- metadata: {
- client_id: this.custosId,
- description: this.selectedDescription,
- owner_id: this.currentUserName
- },
- password: this.selectedPassword
- }
- }
- let response = await this.$store.dispatch('secret/addPasswordCredential', data)
- let dataEN = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
+
+ if (this.selectedPassword == null || this.selectedPassword == '') {
+ this.passwordEmptyError = true
+
+ } else {
+
+ let data = {
client_id: this.custosId,
- entity: {
- id: response.token,
- name: 'Password token',
- description: 'Password credential created for ' + this.selectedDescription,
- type: 'SECRET',
- owner_id: this.currentUserName
+ client_sec: this.custosSec,
+ body: {
+ metadata: {
+ client_id: this.custosId,
+ description: this.selectedDescription,
+ owner_id: this.currentUserName
+ },
+ password: this.selectedPassword
}
}
+ let response = await this.$store.dispatch('secret/addPasswordCredential', data)
+ let dataEN = {
+ client_id: this.custosId,
+ client_sec: this.custosSec,
+ body: {
+ client_id: this.custosId,
+ entity: {
+ id: response.token,
+ name: 'Password token',
+ description: 'Password credential created for ' + this.selectedDescription,
+ type: 'SECRET',
+ owner_id: this.currentUserName
+ }
+ }
+ }
+ await this.$store.dispatch('sharing/createEntity', dataEN)
}
- await this.$store.dispatch('sharing/createEntity', dataEN)
+ this.secItems = await this.getAllCredentials()
+ this.secretsLoading = false
}
- this.secItems = await this.getAllCredentials()
- this.secretsLoading = false
},
async secDeleteButtonPressed() {
diff --git a/custos-demo-gateway/src/components/workspace/Sharing.vue b/custos-demo-gateway/src/components/workspace/Sharing.vue
index e4ba669..1c5ce91 100644
--- a/custos-demo-gateway/src/components/workspace/Sharing.vue
+++ b/custos-demo-gateway/src/components/workspace/Sharing.vue
@@ -6,6 +6,12 @@
<div class="row">
<div class="column">
<div class="sharingtable">
+ <div>
+ <b-alert v-model="this.inputErrorPR" variant="danger" dismissible
+ @dismissed="callDismissed">
+ Input validation error
+ </b-alert>
+ </div>
<div v-if="this.permissionTypesLoading" class="d-flex justify-content-center mb-3">
<b-spinner variant="primary" label="Text Centered"></b-spinner>
</div>
@@ -23,6 +29,12 @@
<b-spinner variant="primary" label="Text Centered"></b-spinner>
</div>
<div class="sharingtable">
+ <div>
+ <b-alert v-model="this.inputErrorEnTy" variant="danger" dismissible
+ @dismissed="callDismissed">
+ Input validation error
+ </b-alert>
+ </div>
<b-table striped hover responsive :items="entityTypes" :fields="fields" selectable
ref="selectableTable"
select-mode="single"
@@ -37,6 +49,12 @@
<b-spinner variant="primary" label="Text Centered"></b-spinner>
</div>
<div class="sharingtable">
+ <div>
+ <b-alert v-model="this.inputErrorEn" variant="danger" dismissible
+ @dismissed="callDismissed">
+ Input validation error
+ </b-alert>
+ </div>
<b-table striped hover responsive :items="entities" :fields="entityFields" selectable
ref="selectableTable"
select-mode="single"
@@ -51,6 +69,12 @@
<b-spinner variant="primary" label="Text Centered"></b-spinner>
</div>
<div class="sharingtable">
+ <div>
+ <b-alert v-model="this.sharingError" variant="danger" dismissible
+ @dismissed="callDismissed">
+ Input validation error
+ </b-alert>
+ </div>
<b-table striped hover responsive :items="sharings" :fields="sharingFields" selectable
ref="selectableTable"
select-mode="single"
@@ -103,10 +127,6 @@
<b-modal ref="enModel" scrollable title="Add Entity " ok-title="Add" @ok="addNewEntity">
<div class="groupform">
<div class="groupformItem">
- <p>Id</p>
- <b-form-input v-model="enId"></b-form-input>
- </div>
- <div class="groupformItem">
<p>Name</p>
<b-form-input v-model="enName"></b-form-input>
</div>
@@ -275,7 +295,8 @@
<div v-if="this.isAdminUser" class="column">
<div class="permissionChecker">
<div class="addGr">
- <b-button variant="outline-primary" v-on:click="checkPermissions">Evaluate Permissions</b-button>
+ <b-button variant="outline-primary" v-on:click="checkPermissions">Evaluate Permissions
+ </b-button>
</div>
</div>
</div>
@@ -326,16 +347,16 @@
</b-button>
</div>
<div v-if="!this.evaluating">
- <div v-if="evalutionResult" class="groupform">
- <p class="textCls"> Evalution Status: True </p>
- <p>User has permission</p>
+ <div v-if="evalutionResult" class="groupform">
+ <p class="textCls"> Evalution Status: True </p>
+ <p>User has permission</p>
- </div>
- <div v-if="!evalutionResult" class="groupform">
- <p class="textClsWrng"> Evalution Status: False </p>
- <p>User does not have permission</p>
+ </div>
+ <div v-if="!evalutionResult" class="groupform">
+ <p class="textClsWrng"> Evalution Status: False </p>
+ <p>User does not have permission</p>
- </div>
+ </div>
</div>
</b-modal>
</div>
@@ -395,11 +416,17 @@
selectedShOwType: null,
evalutionResult: false,
permissionTypesLoading: false,
- entityTypesLoading:false,
- entitiesLoading:false,
- sharingsLoading:false,
+ entityTypesLoading: false,
+ entitiesLoading: false,
+ sharingsLoading: false,
evaluating: false,
- defaultGroupName: null
+ defaultGroupName: null,
+ inputErrorPR: false,
+ inputErrorEnTy:false,
+ inputErrorEn:false,
+ sharingError:false,
+
+
}
@@ -407,23 +434,29 @@
methods: {
async addPrType() {
- this.permissionTypesLoading =true
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
+ this.permissionTypesLoading = true
+ if (this.prId == null || this.prName == null || this.prId == '' || this.prName == '') {
+ this.inputErrorPR = true
+ this.permissionTypesLoading = false
+ }
+ if (!this.inputErrorPR) {
+ let data = {
client_id: this.custosId,
- permission_type: {
- id: this.prId,
- name: this.prName,
- description: this.prDesc
+ client_sec: this.custosSec,
+ body: {
+ client_id: this.custosId,
+ permission_type: {
+ id: this.prId,
+ name: this.prName,
+ description: this.prDesc
+ }
}
}
- }
- this.permissionTypes = await this.$store.dispatch('sharing/createPermissionType', data)
- this.permissionTypesLoading = false
+ this.permissionTypes = await this.$store.dispatch('sharing/createPermissionType', data)
+ this.permissionTypesLoading = false
+ }
this.prId = null
this.prName = null
this.prDesc = null
@@ -431,7 +464,7 @@
},
async deletePRType() {
- this.permissionTypesLoading =true
+ this.permissionTypesLoading = true
let data = {
client_id: this.custosId,
client_sec: this.custosSec,
@@ -454,21 +487,28 @@
},
async addNewEnType() {
this.entityTypesLoading = true
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
+ if (this.enTyId == null || this.enTyName == null || this.enTyName==''|| this.enTyId == '') {
+ this.inputErrorEnTy = true
+ this.entityTypesLoading = false
+ }
+ if (!this.inputErrorEnTy) {
+ let data = {
client_id: this.custosId,
- entity_type: {
- id: this.enTyId,
- name: this.enTyName,
- description: this.enTyDesc
+ client_sec: this.custosSec,
+ body: {
+ client_id: this.custosId,
+ entity_type: {
+ id: this.enTyId,
+ name: this.enTyName,
+ description: this.enTyDesc
+ }
}
}
- }
- this.entityTypes = await this.$store.dispatch('sharing/createEntityType', data)
- this.entityTypesLoading = false
+ this.entityTypes = await this.$store.dispatch('sharing/createEntityType', data)
+ this.entityTypesLoading = false
+
+ }
this.enTyId = null
this.enTyName = null
this.enTyDesc = null
@@ -501,28 +541,36 @@
async addNewEntity() {
this.entitiesLoading = true
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
- client_id: this.custosId,
- entity: {
- id: this.enId,
- name: this.enName,
- description: this.enDesc,
- type: this.selectedEntityType.id,
- owner_id: this.currentUserName
- }
- }
+ if (this.enName == null || this.enName =='') {
+ this.inputErrorEn = true
+ this.entitiesLoading = false
}
- this.entities = await this.$store.dispatch('sharing/createEntity', data)
- this.entitiesLoading = false
+ if (!this.inputErrorEn) {
+ this.enId = this.enName + "_" + this.makeid(15)
+ let data = {
+ client_id: this.custosId,
+ client_sec: this.custosSec,
+ body: {
+ client_id: this.custosId,
+ entity: {
+ id: this.enId,
+ name: this.enName,
+ description: this.enDesc,
+ type: this.selectedEntityType.id,
+ owner_id: this.currentUserName
+ }
+ }
+ }
+
+ this.entities = await this.$store.dispatch('sharing/createEntity', data)
+ this.entitiesLoading = false
+ this.sharings = await this.loadSharings()
+ }
this.enId = null
this.enName = null
this.enDesc = null
this.selectedEntityType = null
- this.sharings = await this.loadSharings()
},
@@ -554,37 +602,47 @@
async addNewSharing() {
this.sharingsLoading = true
- let data = {
- client_id: this.custosId,
- client_sec: this.custosSec,
- body: {
- client_id: this.custosId,
- entity: {
- id: this.defaultEntityId.id
- },
- permission_type: {
- id: this.defaultPermissionType.id
- },
- owner_id: [this.defaultOwner],
- cascade: true
+ if (this.defaultEntityId == null || this.defaultPermissionType == null
+ || (this.defaultGroupName == null && this.defaultOwner == null)) {
+ this.sharingError = true
+ this.sharingsLoading = false
- }
}
- if (this.defaultSharingType === 'USERS') {
- let response = await this.$store.dispatch('sharing/shareEntityWithUsers', data)
+ if (!this.sharingError) {
+ let data = {
+ client_id: this.custosId,
+ client_sec: this.custosSec,
+ body: {
- if (response) {
- this.sharings = await this.loadSharings()
+ client_id: this.custosId,
+ entity: {
+ id: this.defaultEntityId.id
+ },
+ permission_type: {
+ id: this.defaultPermissionType.id
+ },
+ owner_id: [this.defaultOwner],
+ cascade: true
+
+ }
}
- } else {
- console.log(this.defaultGroupName)
- data.body.owner_id = [this.defaultGroupName.id]
- console.log(data)
- let response = await this.$store.dispatch('sharing/shareEntityWithGroups', data)
- if (response) {
- this.sharings = await this.loadSharings()
+
+ if (this.defaultSharingType === 'USERS') {
+ let response = await this.$store.dispatch('sharing/shareEntityWithUsers', data)
+
+ if (response) {
+ this.sharings = await this.loadSharings()
+ }
+ } else {
+ console.log(this.defaultGroupName)
+ data.body.owner_id = [this.defaultGroupName.id]
+ console.log(data)
+ let response = await this.$store.dispatch('sharing/shareEntityWithGroups', data)
+ if (response) {
+ this.sharings = await this.loadSharings()
+ }
}
}
this.sharingsLoading = false
@@ -704,7 +762,7 @@
username: this.currentUserName
}
if (this.isAdminUser) {
- return await this.$store.dispatch('group/loadAllGroups', data)
+ return await this.$store.dispatch('group/loadAllGroups', data)
} else {
let grs = []
grs = await this.$store.dispatch('group/getAllGroupsOfUser', data)
@@ -713,7 +771,7 @@
gr.ownerId = gr.owner_id
groups.push(gr)
})
- return groups
+ return groups
}
},
@@ -785,6 +843,23 @@
await this.$router.push('/workspace')
},
+ makeid(length) {
+ let result = '';
+ let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ let charactersLength = characters.length;
+ for (var i = 0; i < length; i++) {
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
+ }
+ return result;
+ },
+
+ async callDismissed(){
+ this.inputErrorEn = false
+ this.inputErrorEnTy = false
+ this.inputErrorEn = false
+ this.sharingError =false
+ }
+
},
async mounted() {
diff --git a/custos-demo-gateway/src/components/workspace/Users.vue b/custos-demo-gateway/src/components/workspace/Users.vue
index f5d1e55..a97f32e 100644
--- a/custos-demo-gateway/src/components/workspace/Users.vue
+++ b/custos-demo-gateway/src/components/workspace/Users.vue
@@ -5,7 +5,7 @@
<b-button href="#" v-on:click="goToWorkspace">Go to Workspace</b-button>
</div>
<div class="userSearchBar">
- <b-input-group prepend="Username" class="mt-3">
+ <b-input-group prepend="User" class="mt-3">
<b-form-input v-model="searchUsername"></b-form-input>
<b-input-group-append>
<b-button variant="outline-success" v-on:click="this.searchResult">
@@ -196,7 +196,7 @@
}
],
- statusOptions: ['ACTIVE', 'DISABLE'],
+ statusOptions: ['ACTIVE', 'DEACTIVE'],
scopes: ['TENANT', 'CLIENT'],
tenantroles: [],
clientroles: [],
@@ -271,7 +271,7 @@
await this.loadUsers()
} else {
let data = {
- offset: 0, limit: 1, client_id: this.custosId, client_sec: this.custosSec,
+ offset: 0, limit: 5, client_id: this.custosId, client_sec: this.custosSec,
username: this.searchUsername
}
await this.$store.dispatch('user/users', data)
@@ -345,7 +345,9 @@
if (this.isAdminUser) {
this.rowSelectedScope = this.selectedRoleItem[0].scope
this.rowSelectedRole = this.selectedRoleItem[0].name
- this.$refs.roleModelSelected.show()
+ if (this.rowSelectedRole !== 'offline_access' && this.rowSelectedRole !== 'uma_authorization') {
+ this.$refs.roleModelSelected.show()
+ }
}
}
},
@@ -428,41 +430,43 @@
this.loadUsers()
},
async deleteRoleOkPressed() {
- this.operationCompleted = false
- let accessToken = await this.$store.getters['identity/getAccessToken']
- let bd = {};
- if (this.rowSelectedScope === 'TENANT') {
- bd = {
- user_token: accessToken,
- body: {
- roles: [this.rowSelectedRole],
- username: this.selectedUsername
+ this.operationCompleted = false
+ let accessToken = await this.$store.getters['identity/getAccessToken']
+ let bd = {};
+ if (this.rowSelectedScope === 'TENANT') {
+ bd = {
+ user_token: accessToken,
+ body: {
+ roles: [this.rowSelectedRole],
+ username: this.selectedUsername
+ }
+ }
+ } else {
+ bd = {
+ user_token: accessToken,
+ body: {
+ client_roles: [this.rowSelectedRole],
+ username: this.selectedUsername
+ }
}
}
- } else {
- bd = {
- user_token: accessToken,
- body: {
- client_roles: [this.rowSelectedRole],
- username: this.selectedUsername
- }
+
+ let deleted = await this.$store.dispatch('user/deleteRoleFromUser', bd)
+ if (deleted) {
+
+ let newRoles = []
+ this.selectedRoles.forEach(atr => {
+
+ if (atr.name != this.rowSelectedRole) {
+ newRoles.push(atr)
+ }
+ this.selectedRoles = newRoles
+ })
}
- }
+ this.operationCompleted = true
+ this.loadUsers()
- let deleted = await this.$store.dispatch('user/deleteRoleFromUser', bd)
- if (deleted) {
- let newRoles = []
- this.selectedRoles.forEach(atr => {
-
- if (atr.name != this.rowSelectedRole) {
- newRoles.push(atr)
- }
- this.selectedRoles = newRoles
- })
- }
- this.operationCompleted = true
- this.loadUsers()
},
async loadUsers() {
@@ -498,7 +502,7 @@
first_name: obj.first_name,
last_name: obj.last_name,
email: obj.email,
- status: obj.state,
+ status: (obj.state=='ACTIVE')?obj.state:'DEACTIVE',
attributes: [],
roles: []
}
diff --git a/custos-demo-gateway/src/service/group_management.js b/custos-demo-gateway/src/service/group_management.js
index 270f183..4f7f6e0 100644
--- a/custos-demo-gateway/src/service/group_management.js
+++ b/custos-demo-gateway/src/service/group_management.js
@@ -173,6 +173,17 @@
}
return api().get(endpoint, {params: parm, headers: authHeader})
+ },
+
+ hasAccess(params) {
+ let authHeader = {'Authorization': 'Bearer ' + btoa(params.client_id + ':' + params.client_sec)}
+ let endpoint = groupMgtEndpoint + "/user/group/access"
+ let parm = {
+ 'group_id': params.groupId,
+ 'username':params.username,
+ 'type': params.type
+ }
+ return api().get(endpoint, {params: parm, headers: authHeader})
}
diff --git a/custos-demo-gateway/src/store/modules/group.store.js b/custos-demo-gateway/src/store/modules/group.store.js
index fa55477..7735523 100644
--- a/custos-demo-gateway/src/store/modules/group.store.js
+++ b/custos-demo-gateway/src/store/modules/group.store.js
@@ -115,6 +115,12 @@
async reset({commit}, data) {
commit('RESET')
return true
+ },
+
+ // eslint-disable-next-line no-unused-vars
+ async hasAccess({commit}, data) {
+ let response = await group_management.hasAccess(data)
+ return response.data
}
}