unclean SPARC
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
class onboardingUserModel extends EICPluralModel {
|
||||
|
||||
constructor(privileges) {
|
||||
|
||||
super('/organisations', privileges);
|
||||
|
||||
this.singletonClass = class {
|
||||
itemData = {
|
||||
uuid: null,
|
||||
firstname: null,
|
||||
lastname: null,
|
||||
role: null,
|
||||
organisations: []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readOrganisation(pic) {
|
||||
if(!this.hasPrivilege('read')) return( new Promise((resolve, reject) => reject()));
|
||||
|
||||
let endpoint = this.getApiEndpoint('read');
|
||||
let uri = endpoint.uri.replace('{pic}',pic)
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
this.loadData(serverData.payload)
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
searchOrganisation(pic) {
|
||||
// This is publicly avail, don't check until ML understand what anonymous means
|
||||
// if(!this.hasPrivilege('search')) return( new Promise((resolve, reject) => reject()))
|
||||
|
||||
let endpoint = this.getApiEndpoint('search');
|
||||
let uri = endpoint.uri
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, {'search': pic })
|
||||
.then( async serverData => {
|
||||
this.loadData(serverData.payload)
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
registerOrganisationAccess(orgData) {
|
||||
if(!this.hasPrivilege('apply')) return( new Promise((resolve, reject) => reject()));
|
||||
let endpoint = this.getApiEndpoint('apply')
|
||||
let uri = endpoint.uri.replace('{pic}',orgData.pic).replace('{uid}', app.User.identity.uuid);
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, {
|
||||
status: 'pending',
|
||||
organisationLink: '/applicant/{pic}'.replace('{pic}',orgData.pic)
|
||||
})
|
||||
.then( async serverData => {
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
requestOrganisationAccess(orgData) {
|
||||
if(!this.hasPrivilege('apply')) return( new Promise((resolve, reject) => reject()));
|
||||
|
||||
let endpoint = this.getApiEndpoint('apply')
|
||||
let uri = endpoint.uri.replace('{pic}',orgData.pic).replace('{uid}', app.User.identity.uuid);
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, {
|
||||
status: 'pending',
|
||||
organisationLink: '/applicant/{pic}'.replace('{pic}',orgData.pic)
|
||||
})
|
||||
.then( async serverData => {
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// MFA: needed here ? handled thru dashboard
|
||||
// Nike: Yes, good place, for rel2
|
||||
acceptRegistrationAccess(uid, pic) {
|
||||
if(!this.hasPrivilege('grant')) return( new Promise((resolve, reject) => reject()));
|
||||
let endpoint = this.getApiEndpoint('grant').replace('{pic}',pic).replace('{uid}', app.User.identity.uuid);
|
||||
let uri = endpoint.uri
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, {
|
||||
status: 'pending',
|
||||
organisationLink: '/applicant/{pic}'.replace('{pic}',pic)
|
||||
} )
|
||||
.then( async serverData => {
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// MFA: needed here ? handled thru dashboard
|
||||
// Nike: Yes, good place, for rel2
|
||||
denyRegistrationAccess(uid, pic) {
|
||||
if(!this.hasPrivilege('revoke')) return( new Promise((resolve, reject) => reject()));
|
||||
let endpoint = this.getApiEndpoint('revoke').replace('{pic}',pic).replace('{uid}', app.User.identity.uuid);
|
||||
let uri = endpoint.uri
|
||||
|
||||
return (
|
||||
this.request(uri, endpoint.method, {
|
||||
status: 'pending',
|
||||
organisationLink: '/applicant/{pic}'.replace('{pic}',pic)
|
||||
} )
|
||||
.then( async serverData => {
|
||||
return(serverData.payload)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('onboardingUserModel', onboardingUserModel);
|
||||
Reference in New Issue
Block a user