cancel
Showing results for 
Search instead for 
Did you mean: 

user created using javascript API not able to login

spatils
Champ in-the-making
Champ in-the-making
I have written a custom javascript API to create user.
I am able create user using following code. I can verify other properties of user from admin console.
But newly created user is not able to login.
When I try to change password of the user from admin console I get following error
"A system error happened during the operation: User name does not exist: tt1"

Am I missing somthing over here?
Is it possible to create a working user using java script API Or I must use java code for this operation?

model.username = args.username;
model.firstname=args.firstname;
model.lastname=args.lastname;
model.password=args.password;
model.email=args.email;

var person = people.createPerson(args.username);
person.properties["firstName"]=args.firstname;
person.properties["lastName"]=args.lastname;
person.properties["email"]=args.email;
person.properties["userPassword"]=args.password;
person.properties["password"]=args.password;
person.properties["sizeQuota"]="1073741824";                                                 
person.properties["disableAccount"]=false;
person.properties["usr:password"] = args.password;
person.properties["usr:credentialsExpire"]=false;
person.properties["usr:userName"]=args.username;
person.properties["usr:name"]=args.username;

person.save();
person.setPermission("Write", args.username);
person.setPermission("Delete", args.username);
person.setPermission("Read", args.username);
person.setOwner(args.username) ;
person.save();
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
There's already a couple of methods on the Java Script person object to create people.

spatils
Champ in-the-making
Champ in-the-making
Thanks for the replay.
I am using 3.0 version of Alfresco.
createPerson is the only available API in this version.
Let me know if I am missing something.

hsohaib
Champ on-the-rise
Champ on-the-rise
i had the same problem but solved it, in case someone else need it here is how you create a new user using javascript :


var newUserName = "newUser";
var newUserPassword = "password";
var newUser = people.createPerson(newUserName,"firstName", "lastName","myEmail@somedomain.com", newUserPassword ,true);
newUser.properties["cm:homeFolder"]=companyhome.createFolder(newUserName);
newUser.save();

iann
Champ in-the-making
Champ in-the-making
Thanks for that - you solved an issue with the way I was creating my users. Very helpful.

sselvan
Champ in-the-making
Champ in-the-making
@spatils

Though "@hsohaib" solved this issue, I just had a comment on your code -

I am guessing the problem in your code could be that - the home folder is not set for the user.