mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Creation of Person (in People JS API) with generated user name is now accompanied with optional creation of either enabled or disabled user account
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9537 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
11ef50b017
commit
4f15d38283
@ -140,16 +140,23 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
/**
|
/**
|
||||||
* Create a Person with a generated user name
|
* Create a Person with a generated user name
|
||||||
*
|
*
|
||||||
* @param createUserAccount set to 'true' to create a user account for the person with the generated user name
|
* @param createUserAccount
|
||||||
* and password
|
* set to 'true' to create a user account for the person with the
|
||||||
* @return the person node (type cm:person) created or null if the person could not be created
|
* generated user name and a generated password
|
||||||
|
* @param setAccountEnabled
|
||||||
|
* set to 'true' to create enabled user account, or 'false' to
|
||||||
|
* create disabled user account for created person.
|
||||||
|
* @return the person node (type cm:person) created or null if the person
|
||||||
|
* could not be created
|
||||||
*/
|
*/
|
||||||
public ScriptNode createPerson(boolean createUserAccount)
|
public ScriptNode createPerson(boolean createUserAccount,
|
||||||
|
boolean setAccountEnabled)
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatory("createUserAccount", createUserAccount);
|
ParameterCheck.mandatory("createUserAccount", createUserAccount);
|
||||||
|
ParameterCheck.mandatory("setAccountEnabled", setAccountEnabled);
|
||||||
|
|
||||||
ScriptNode person = null;
|
ScriptNode person = null;
|
||||||
|
|
||||||
// generate user name
|
// generate user name
|
||||||
String userName = usernameGenerator.generateUserName();
|
String userName = usernameGenerator.generateUserName();
|
||||||
|
|
||||||
@ -157,20 +164,32 @@ public final class People extends BaseScopableProcessorExtension
|
|||||||
if (!personService.personExists(userName))
|
if (!personService.personExists(userName))
|
||||||
{
|
{
|
||||||
person = createPerson(userName);
|
person = createPerson(userName);
|
||||||
|
|
||||||
if (createUserAccount)
|
if (createUserAccount)
|
||||||
{
|
{
|
||||||
// generate password
|
// generate password
|
||||||
char[] password = passwordGenerator.generatePassword().toCharArray();
|
char[] password = passwordGenerator.generatePassword().toCharArray();
|
||||||
|
|
||||||
// create account for person with generated userName and password
|
// create account for person with generated userName and
|
||||||
|
// password
|
||||||
mutableAuthenticationDao.createUser(userName, password);
|
mutableAuthenticationDao.createUser(userName, password);
|
||||||
|
mutableAuthenticationDao.setEnabled(userName, setAccountEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable person's user account
|
||||||
|
*
|
||||||
|
* @param userName user name of person for which to enable user account
|
||||||
|
*/
|
||||||
|
public void enablePerson(String userName)
|
||||||
|
{
|
||||||
|
mutableAuthenticationDao.setEnabled(userName, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Person with the given user name
|
* Create a Person with the given user name
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user