javascript - 如何从管理员为新用户创建的 Alfresco UI 页面获取密码?

标签 javascript java alfresco email alfresco-share

我使用此代码自动生成邮件。现在的问题是邮件中显示的密码是脚本生成的密码。我希望从露天新用户页面获取密码,其中管理员为新用户创建了密码,而不是任何随机字符串。 下面是我为自动邮件生成生成的脚本。

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/

相关文章:

javascript - 修复由 tumblr 的模板系统发出的损坏的 html

javascript - d3.js 中的文本输入字段

java - 将方法参数表示为 "short"原始类型

java - Java/Android Realm - 保留查询/结果的状态

alfresco - 使用 java 实现在 Alfresco 中上传文件

javascript - 添加更多字符时正则表达式不匹配

javascript - vuex 不识别突变

java - 如何实现用组单例分隔的 spring

java - 户外问题 : URI cannot be imported as it is not defined (with prefix

alfresco - Aikau 基础知识 - 有效负载 101