我使用此代码自动生成邮件。现在的问题是邮件中显示的密码是脚本生成的密码。我希望从露天新用户页面获取密码,其中管理员为新用户创建了密码,而不是任何随机字符串。 下面是我为自动邮件生成生成的脚本。
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);
}
}
请指导我如何进一步进行。
最佳答案
您无法从哈希值中解码密码。您只能encode new password and match it with hash .
您可以修改 Alfresco Share 以在自定义用户方面存储原始密码,但这是非常糟糕的做法。管理员不应知道用户密码。
关于javascript - 如何从管理员为新用户创建的 Alfresco UI 页面获取密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40260401/