mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix to Invite REST API where inviteeUserName arg was not correctly checked when inviting external users.
Also cleanup the related .js scripts to use spaces not tabs - significantly aids debugging in the script debugger. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13913 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,42 +1,41 @@
|
|||||||
/**
|
/**
|
||||||
* List/Search invitations implementation
|
* List/Search invitations implementation
|
||||||
*/
|
*/
|
||||||
|
function main()
|
||||||
function main ()
|
|
||||||
{
|
{
|
||||||
// Get the site id
|
// Get the site id
|
||||||
var urlElements = url.extension.split("/");
|
var urlElements = url.extension.split("/");
|
||||||
var shortName = urlElements[0];
|
var shortName = urlElements[0];
|
||||||
|
|
||||||
// Get the args
|
// Get the args
|
||||||
var inviteeUserName = args["inviteeUserName"];
|
var inviteeUserName = args["inviteeUserName"];
|
||||||
var invitationType = args["invitationType"];
|
var invitationType = args["invitationType"];
|
||||||
var resourceType = args["resourceType"];
|
var resourceType = args["resourceType"];
|
||||||
var resourceName = args["resourceName"];
|
var resourceName = args["resourceName"];
|
||||||
|
|
||||||
var props = {};
|
var props = {};
|
||||||
|
|
||||||
if(inviteeUserName != null)
|
if (inviteeUserName != null)
|
||||||
{
|
{
|
||||||
props.inviteeUserName = inviteeUserName
|
props.inviteeUserName = inviteeUserName
|
||||||
}
|
}
|
||||||
if(invitationType != null)
|
if (invitationType != null)
|
||||||
{
|
{
|
||||||
props.invitationType = invitationType
|
props.invitationType = invitationType
|
||||||
}
|
}
|
||||||
if(resourceType != null)
|
if (resourceType != null)
|
||||||
{
|
{
|
||||||
props.resourceType = resourceType
|
props.resourceType = resourceType
|
||||||
}
|
}
|
||||||
if(resourceName != null)
|
if (resourceName != null)
|
||||||
{
|
{
|
||||||
props.resourceName = resourceName
|
props.resourceName = resourceName
|
||||||
}
|
}
|
||||||
|
|
||||||
var invites = invitations.listInvitations(props);
|
var invites = invitations.listInvitations(props);
|
||||||
|
|
||||||
// Pass the information to the template
|
// Pass the information to the template
|
||||||
model.invitations = invites;
|
model.invitations = invites;
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
@@ -1,33 +1,33 @@
|
|||||||
// Cancel invitation for a web site
|
/**
|
||||||
|
* Cancel invitation for a web site
|
||||||
|
*/
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
// Get the url values
|
// Get the url values
|
||||||
var urlElements = url.extension.split("/");
|
var urlElements = url.extension.split("/");
|
||||||
var shortName = urlElements[0];
|
var shortName = urlElements[0];
|
||||||
var inviteId = urlElements[2];
|
var inviteId = urlElements[2];
|
||||||
|
|
||||||
// Get the site
|
// Get the site
|
||||||
var site = siteService.getSite(shortName);
|
var site = siteService.getSite(shortName);
|
||||||
if (site == null)
|
if (site == null)
|
||||||
{
|
{
|
||||||
// Site cannot be found
|
// Site cannot be found
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to cancel an invitation here
|
||||||
|
var invitation = site.getInvitation(inviteId);
|
||||||
|
if (invitation == null)
|
||||||
|
{
|
||||||
|
// Site cannot be found
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Need to cancel an invitation here
|
// Cancel the invitation
|
||||||
var invitation = site.getInvitation(inviteId);
|
invitation.cancel();
|
||||||
if (invitation == null)
|
|
||||||
{
|
|
||||||
// Site cannot be found
|
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel the invitation
|
|
||||||
invitation.cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
@@ -3,27 +3,26 @@
|
|||||||
*/
|
*/
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
|
// Get the site id
|
||||||
|
var urlElements = url.extension.split("/");
|
||||||
|
var shortName = urlElements[0];
|
||||||
|
var inviteId = urlElements[2];
|
||||||
|
|
||||||
// Get the site id
|
var site = siteService.getSite(shortName);
|
||||||
var urlElements = url.extension.split("/");
|
if (site == null)
|
||||||
var shortName = urlElements[0];
|
{
|
||||||
var inviteId = urlElements[2];
|
// Site cannot be found
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var site = siteService.getSite(shortName);
|
var invitation = site.getInvitation(inviteId);
|
||||||
if (site == null)
|
if (invitation == null)
|
||||||
{
|
{
|
||||||
// Site cannot be found
|
// Site cannot be found
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var invitation = site.getInvitation(inviteId);
|
|
||||||
if (invitation == null)
|
|
||||||
{
|
|
||||||
// Site cannot be found
|
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The invitation :" + inviteId + " for web site :" + shortName + ", does not exist.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pass the model to the template
|
// Pass the model to the template
|
||||||
model.invitation = invitation;
|
model.invitation = invitation;
|
||||||
@@ -31,4 +30,3 @@ function main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
@@ -3,137 +3,132 @@
|
|||||||
*/
|
*/
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
|
var invitation = null;
|
||||||
|
|
||||||
var invitation = null;
|
// Get the web site site
|
||||||
|
var shortName = url.extension.split("/")[0];
|
||||||
|
var site = siteService.getSite(shortName);
|
||||||
|
if (site == null)
|
||||||
|
{
|
||||||
|
// Site cannot be found
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the web site site
|
if (!json.has("invitationType"))
|
||||||
var shortName = url.extension.split("/")[0];
|
{
|
||||||
var site = siteService.getSite(shortName);
|
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has not been set.");
|
||||||
if (site == null)
|
return;
|
||||||
{
|
}
|
||||||
// Site cannot be found
|
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!json.has("invitationType"))
|
// Get the role
|
||||||
{
|
var invitationType = json.get("invitationType");
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has not been set.");
|
if (invitationType == null || invitationType.length == 0)
|
||||||
return;
|
{
|
||||||
}
|
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType is null or empty.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the role
|
if (!invitationType.match("[MODERATED]|[NOMINATED]"))
|
||||||
var invitationType = json.get("invitationType");
|
{
|
||||||
if (invitationType == null || invitationType.length == 0)
|
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has does not have a correct value.");
|
||||||
{
|
return;
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType is null or empty.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!invitationType.match("[MODERATED]|[NOMINATED]"))
|
if (invitationType == "MODERATED")
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The invitationType has does not have a correct value.");
|
// Check mandatory parameters
|
||||||
return;
|
if (!json.has("inviteeRoleName"))
|
||||||
}
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(invitationType == "MODERATED")
|
if (!json.has("inviteeUserName"))
|
||||||
{
|
{
|
||||||
// Check mandatory parameters
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeUserName has not been set.");
|
||||||
if(!json.has("inviteeRoleName"))
|
return;
|
||||||
{
|
}
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!json.has("inviteeUserName"))
|
// Get the role
|
||||||
{
|
var inviteeRoleName = json.get("inviteeRoleName");
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeUserName has not been set.");
|
if (inviteeRoleName == null || inviteeRoleName == "")
|
||||||
return;
|
{
|
||||||
}
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the role
|
var inviteeComments = json.get("inviteeComments");
|
||||||
var inviteeRoleName = json.get("inviteeRoleName");
|
if (inviteeComments == null)
|
||||||
if (inviteeRoleName == null || inviteeRoleName == "")
|
{
|
||||||
{
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeComments has not been set.");
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var inviteeComments = json.get("inviteeComments");
|
var inviteeUserName = json.get("inviteeUserName");
|
||||||
if (inviteeComments == null)
|
if (inviteeUserName == null || inviteeUserName == "")
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeComments has not been set.");
|
status.setCode(status.STATUS_BAD_REQUEST, "The userName has not been set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inviteeUserName = json.get("inviteeUserName");
|
invitation = site.inviteModerated(inviteeComments, inviteeUserName, inviteeRoleName);
|
||||||
if (inviteeUserName == null || inviteeUserName == "")
|
}
|
||||||
{
|
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The userName has not been set.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
invitation = site.inviteModerated(inviteeComments, inviteeUserName, inviteeRoleName);
|
if (invitationType == "NOMINATED")
|
||||||
}
|
{
|
||||||
|
// Get mandatory properties
|
||||||
|
if (!json.has("inviteeRoleName"))
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var inviteeRoleName = json.get("inviteeRoleName");
|
||||||
|
if (inviteeRoleName == null || inviteeRoleName == "")
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName is null or empty.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var serverPath = json.get("serverPath");
|
||||||
|
var acceptUrl = json.get("acceptURL");
|
||||||
|
var rejectUrl = json.get("rejectURL");
|
||||||
|
|
||||||
if(invitationType == "NOMINATED")
|
// Get the optional properties
|
||||||
{
|
if (json.has("inviteeUserName") && json.get("inviteeUserName") != "")
|
||||||
|
{
|
||||||
|
invitation = site.inviteNominated(json.get("inviteeUserName"), inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get mandatory properties
|
||||||
|
if (!json.has("inviteeFirstName"))
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeFirstName has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!json.has("inviteeLastName"))
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeLastName has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!json.has("inviteeEmail"))
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeEmail has not been set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get Mandatory properties
|
var inviteeFirstName = json.get("inviteeFirstName") ;
|
||||||
if(!json.has("inviteeRoleName"))
|
var inviteeLastName = json.get("inviteeLastName") ;
|
||||||
{
|
var inviteeEmail = json.get("inviteeEmail") ;
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName has not been set.");
|
invitation = site.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
var inviteeRoleName = json.get("inviteeRoleName");
|
|
||||||
if (inviteeRoleName == null || inviteeRoleName == "" )
|
|
||||||
{
|
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeRoleName is null or empty.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var serverPath = json.get("serverPath");
|
|
||||||
var acceptUrl = json.get("acceptURL");
|
|
||||||
var rejectUrl = json.get("rejectURL");
|
|
||||||
|
|
||||||
/**
|
// Pass the model to the results template
|
||||||
* Get the optional properties
|
model.site = site;
|
||||||
*/
|
model.invitation = invitation;
|
||||||
if(json.has("inviteeUserName"))
|
|
||||||
{
|
|
||||||
var inviteeUserName = json.get("inviteeUserName");
|
|
||||||
invitation = site.inviteNominated(inviteeUserName, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get Mandatory properties
|
|
||||||
if(!json.has("inviteeFirstName"))
|
|
||||||
{
|
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeFirstName has not been set.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!json.has("inviteeLastName"))
|
|
||||||
{
|
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeLastName has not been set.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!json.has("inviteeEmail"))
|
|
||||||
{
|
|
||||||
status.setCode(status.STATUS_BAD_REQUEST, "The inviteeEmail has not been set.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var inviteeFirstName = json.get("inviteeFirstName") ;
|
status.code = status.STATUS_CREATED;
|
||||||
var inviteeLastName = json.get("inviteeLastName") ;
|
|
||||||
var inviteeEmail = json.get("inviteeEmail") ;
|
|
||||||
invitation = site.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRoleName, serverPath, acceptUrl, rejectUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pass the model to the results template
|
|
||||||
model.site = site;
|
|
||||||
model.invitation = invitation;
|
|
||||||
|
|
||||||
status.code = status.STATUS_CREATED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
@@ -1,40 +1,39 @@
|
|||||||
/**
|
/**
|
||||||
* List invitations implementation
|
* List invitations implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function main ()
|
function main ()
|
||||||
{
|
{
|
||||||
// Get the site id
|
// Get the site id
|
||||||
var urlElements = url.extension.split("/");
|
var urlElements = url.extension.split("/");
|
||||||
var shortName = urlElements[0];
|
var shortName = urlElements[0];
|
||||||
|
|
||||||
// Get the args
|
// Get the args
|
||||||
var inviteeUserName = args["inviteeUserName"];
|
var inviteeUserName = args["inviteeUserName"];
|
||||||
var invitationType = args["invitationType"];
|
var invitationType = args["invitationType"];
|
||||||
|
|
||||||
var site = siteService.getSite(shortName);
|
var site = siteService.getSite(shortName);
|
||||||
if (site == null)
|
if (site == null)
|
||||||
{
|
{
|
||||||
// Site cannot be found
|
// Site cannot be found
|
||||||
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
status.setCode(status.STATUS_NOT_FOUND, "The site " + shortName + " does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var props = {};
|
var props = {};
|
||||||
|
|
||||||
if(inviteeUserName != null)
|
if (inviteeUserName != null)
|
||||||
{
|
{
|
||||||
props.inviteeUserName = inviteeUserName
|
props.inviteeUserName = inviteeUserName
|
||||||
}
|
}
|
||||||
if(invitationType != null)
|
if (invitationType != null)
|
||||||
{
|
{
|
||||||
props.invitationType = invitationType
|
props.invitationType = invitationType
|
||||||
}
|
}
|
||||||
|
|
||||||
var invitations = site.listInvitations(props);
|
var invitations = site.listInvitations(props);
|
||||||
|
|
||||||
// Pass the information to the template
|
// Pass the information to the template
|
||||||
model.invitations = invitations;
|
model.invitations = invitations;
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
Reference in New Issue
Block a user