使用撇号电子邮件向新用户发送帐户详细信息

时间:2018-04-03 00:32:46

标签: apostrophe-cms

我正在阅读以下有关如何使用apostrophe-email模块进行密码重置的信息:

但是,我怀疑,如果拥有管理员权限的任何用户代表他们创建了自己的帐户,此模块是否也向具有帐户详细信息的新用户发送确认/激活电子邮件

否则,有关如何实现这一目标的任何建议/建议吗?

1 个答案:

答案 0 :(得分:0)

email模块实现了所有模块都可用的afterInsert方法。有关详细信息,请参阅[https://apostrophecms.org/docs/tutorials/howtos/email.html](apostrophecms电子邮件HOWTO)。

此模块专注于一项工作 - 提供电子邮件 - 并不特别与帐户创建有关。而在apostrophe-login module has a password reset feature that sends email时,它目前不会在创建帐户时发送电子邮件。但是,您可以通过在项目级别为您自己的代码中的apostrophe-login模块编写// in lib/modules/apostrophe-users/index.js module.exports = { email: { // default "from" address for this module from: 'example@example.com' }, construct: function(self, options) { self.afterInsert = function(req, piece, options, callback) { return self.email(req, 'emailInserted', { piece: piece }, { // can also specify from and other // valid properties for nodemailer messages here to: piece.email, subject: 'A new account was created' }, callback ); }; } }; 方法来自行完成此操作:

func callLoginPostAPI(){
    let param:[String:Any] = ["email":"\(txtFieldUsername.text!)","password":"\(txtFieldPassword.text!)"]
    print(param)
    WebServiceHelper.sharedInstance.loginWithDetails(param)
    { (isSuccess, result) in

        if isSuccess == false{
            print("error")
        }
        else {
            print("Success")
            let dict = result as! [String:Any]
            print(dict)

            if(Constant.statusCode==200)
            {
                   Constant.userToken=dict["auth_token"] as! String
                    DispatchQueue.main.async {
                        let token = CommonMethods.nullToNil(dict["auth_token"])
                        if let t = token{
                            let userDefault = UserDefaults.standard
                            userDefault.set("\(t)", forKey: Constant.tknKey)
                            Constant.userToken = "\(t)"
                            print(Constant.userToken)
                            userDefault.synchronize()
                            self.callUserProfile()
                        }
}

当插入不同类型的片段时,几乎不需要修改电子邮件教程中用于发送电子邮件的示例的代码。这是有效的,因为用户也是件。

请注意,此处未公开密码。出于安全原因,它很快就会从对象中删除。你永远不应该通过电子邮件发送密码。

相关问题