From 4f15d38283437e210bd6cbae6cec4c6f07e16b51 Mon Sep 17 00:00:00 2001 From: Glen Johnson Date: Sun, 22 Jun 2008 23:39:51 +0000 Subject: [PATCH] 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 --- .../org/alfresco/repo/jscript/People.java | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/source/java/org/alfresco/repo/jscript/People.java b/source/java/org/alfresco/repo/jscript/People.java index 3db90d388c..8d02860dfa 100644 --- a/source/java/org/alfresco/repo/jscript/People.java +++ b/source/java/org/alfresco/repo/jscript/People.java @@ -140,16 +140,23 @@ public final class People extends BaseScopableProcessorExtension /** * 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 - * and password - * @return the person node (type cm:person) created or null if the person could not be created + * @param createUserAccount + * set to 'true' to create a user account for the person with the + * 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("setAccountEnabled", setAccountEnabled); + ScriptNode person = null; - + // generate user name String userName = usernameGenerator.generateUserName(); @@ -157,20 +164,32 @@ public final class People extends BaseScopableProcessorExtension if (!personService.personExists(userName)) { person = createPerson(userName); - + if (createUserAccount) { // generate password 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.setEnabled(userName, setAccountEnabled); } } - + 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 *