How to fetch password from Alfresco UI page which has been created by admin for the new user?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 02:45:45

问题


I had used this code for auto generation of mails. Now the problem is password shown in the mail is the password as generated by the script. I want the password to be fetched from alfresco new user page, where the admin has created the password for the new user not any random string. Below is the script that i generated for automatic mail generation.

if (document.isContainer && document.displayPath == "/Company Home/User Homes") {
var owner = document.properties["cm:owner"];
var pNode = people.getPerson(owner);
if (pNode!=null && pNode.exists()){

    var userName = pNode.properties.userName;
    var email = pNode.properties.email;
    var randPassword = Math.random().toString(36).substr(2, 30)+"-"+(Date.now());

    people.setPassword(userName, randPassword);
    logger.debug("Invitation mail: User "+userName+" password has been changed.");

    var mail = actions.create("mail");
    //mail.parameters.from = "noreply@customdomain";
    mail.parameters.to = email; 
    mail.parameters.subject = "Welcome to the site, login: "+userName+", password: "+randPassword;
    mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Invite Email Templates/invite_user_email.ftl");
    var templateModel = new Array();
    templateModel['newPassword'] = randPassword; // use ${newPassword} expression inside template
    mail.parameters.template_model = templateModel;
    mail.executeAsynchronously(document);
    logger.debug("Invitation mail has been sent to "+email);
} else {
    logger.warn("Invitation mail: User not found: "+owner);
}
} 

Please guide me how to proceed further.


回答1:


You can't decode password from its hash. You can only encode new password and match it with hash.

You can modify Alfresco Share to store raw password in custom user aspect, but this is very bad practice. Admin shouldn't know user password.




回答2:


The final answer has been posted in Auto-generation of email with username and random password on creation of new user-- by @Imagine



来源:https://stackoverflow.com/questions/40260401/how-to-fetch-password-from-alfresco-ui-page-which-has-been-created-by-admin-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!