1

My task is to do the following in Alfresco:

When a user is created, the password is auto-generated and the login credentials being sent to the users email address directly, instead of the admin having to enter the password and sending it manually to the newly created users.

Please guide me how to start and proceed in this...

APM
  • 29
  • 1
  • 9

2 Answers2

1

You can refer to my answer for Creating user in alfresco

You can write some random algorithm to generate password. Also you can write some EmailService which can send the credential mail to the user.

Community
  • 1
  • 1
  • Hi Sachin, Can you provide me further details as to how to proceed with Email Service program – APM Oct 17 '16 at 11:34
  • You can follow the link given by Yagami above. And If you are using spring framework, you can go for MailSender, This link has nice example [Send mail](http://www.javatpoint.com/spring-java-mail-tutorial) – Sachin Mesare Oct 17 '16 at 11:38
  • If you want properly formated emails, you can go for Velocity Email templates [Velocity Template Example](http://www.springbyexample.org/examples/velocity-email-template.html) this has complete tutorial to send mail with velocity templates – Sachin Mesare Oct 17 '16 at 11:42
  • Is creating a user code necessary? We normally create users in alfresco website. I just need auto created passwords for that I have created a new password generator class. I just want to pass the created password in the mail. – APM Oct 17 '16 at 11:46
  • Sorry, I don't know this. I never gone for Alfresco-share website. All I can help is about the alfresco Services :) – Sachin Mesare Oct 17 '16 at 11:49
  • Ok so please guide me through auto generation of mails. Will try working on the rest – APM Oct 17 '16 at 11:54
1

i know that this answer look's like Sachin Mesare's answer but it's a little bit différente, i will cut my answer to give something in every part of your question

Part 1 : Create User

1 - you have a start of an answer in this post answered by our friend Sachin Mesare Create Alfresco User

2 - you can see this solution maided by Alfresco Community Add a person JAVA API personally i used this method to create and add a person that worked fine for me (do not forget to read all the post : there's an improvement in the bottom)

Part 2 : Send an Email

1 - you can use this wonderful tutorial that give you the path to follow to send an EMail with Java Api Mail Java - Sending Email

2 - you can find so many StackOverFlow questions ( with answers ) that i selected this one Send email using java

Part 3 : Password

you have 2 ways to do something like that

Solution 1 : encrypte/decrypt it (it's a two ways working method) that mean that if you use an algorithme to encrypte it someone can use the same to decrypt your password.

Solution 2 : Hash it that's a one way method that mean if you hash your password no one even you can get the original password, the most well known method to Hash password is sha256

Hope that helped you

Community
  • 1
  • 1
Yagami Light
  • 1,756
  • 4
  • 19
  • 39
  • Thanks a lot will try out with these methods and let you know whether the task is done. – APM Oct 17 '16 at 08:49
  • Feel free to ask if you don't understand something – Yagami Light Oct 17 '16 at 09:15
  • Hi Yagami, I dont want to set any password for the user, the password should be auto created and as an admin I just need to create the user. The password shall be sent to user via a direct mail. So I don't need to specify any username or password in my code. It should be generic for all. – APM Oct 17 '16 at 09:34
  • Any suggestions regarding this... – APM Oct 17 '16 at 09:34
  • do you mean that you don't want to set the username and the password because of traditionally the user set his own username and password and you only have to store it – Yagami Light Oct 17 '16 at 09:36
  • in this case you will nedd to send to `Alfresco` the `password` and the `username` (in clear) – Yagami Light Oct 17 '16 at 09:50
  • Username is fine but not the password. Password should be auto created – APM Oct 17 '16 at 10:05
  • by Alfresco ?!? – Yagami Light Oct 17 '16 at 10:06
  • Yes or in the code – APM Oct 17 '16 at 10:12
  • Is there a way I set a code which can generate password using random string – APM Oct 17 '16 at 10:13
  • Each time I create a user with the username the password will be created for that user (random string) and mail can be send to the user that "You have been registered with the mentioned username and password". – APM Oct 17 '16 at 10:15
  • when you use alfresco to create a user you need to set a user password in default (or make it empty) to generate a random password see this post http://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string – Yagami Light Oct 17 '16 at 10:15
  • Shall I keep it empty then? – APM Oct 17 '16 at 10:18
  • Can you please help me with a sample code.. – APM Oct 17 '16 at 10:18
  • non bad idea if you are looking for my opinion i will make a default password like : myCompany2016 and the first time the user log in you will ask him to change the default password – Yagami Light Oct 17 '16 at 10:20
  • or simply make a link in your email to make him go to a change password interface and simply say it's made to confirme inscription – Yagami Light Oct 17 '16 at 10:21
  • Yes please that will be of great help – APM Oct 17 '16 at 10:21
  • it's an other question that you have to ask ( it's simply an other topic ) – Yagami Light Oct 17 '16 at 10:22
  • I dont want a link just an auto generated mail with an auto generated password..Sounds easy but since a week I have been grinding my head in this – APM Oct 17 '16 at 10:24
  • your solution is to generate it from random like in the post that i give you – Yagami Light Oct 17 '16 at 10:26
  • 1
    Ok will try that too – APM Oct 17 '16 at 10:26
  • Sounds like you have a plan if i have to give my opinion i think that the username : FirstName+ FamilyName and the password : RandomString – Yagami Light Oct 17 '16 at 10:30
  • 1
    In my view it will be like username: nimesh.vatts@alfresco.com password:random string – APM Oct 17 '16 at 10:34
  • I have created a password generator class and auto mail generator class. Now will try passing the password reference to auto mail generator class. Still in doubt whether this will work or not – APM Oct 17 '16 at 11:25
  • do not forget to make it as an answer about your question – Yagami Light Oct 17 '16 at 12:39
  • any feedbacks ?!? – Yagami Light Oct 19 '16 at 10:12
  • Not yet.... Yet I am thinking to start at really basics. How about creating an action or webscript which will automatically send the mail with the password after clicking on "Create User" button in Alfresco New User page? Any ideas on this?? – APM Oct 20 '16 at 05:47
  • it's an other question that you need to ask for it – Yagami Light Oct 20 '16 at 07:33