Custom password/reset service

Hi guys,

I want to know if there is a way to call the password reset api specifying an email template different from the default one. My scenario is this: we have the regular forgot password thing. But one admin user could call a full_user_reset api wich in addition to do the reset password, change some other user parameters in DB and finally send an email to the user with the details of the full reset and the password reset link. Is that possible?

Thanks in advance,

Lucho.

To initiate a password reset request

POST user/password?reset=true
{"email":"youremail@yourdomain.com"}

OR
POST user/password
{"email":"youremail@yourdomain.com","reset":true}

This will email you a confirmation code.
Once you receive the code, you may reset your password with

POST user/password
{"email":"youremail@yourdomain.com","code":"the confirmation code from the email","new_password":"your new password"}

Custom Email Template
You can create a custom template in DF under the config tab or you can create your own template. You can find out more here - http://wiki.dreamfactory.com/DreamFactory/Tutorials/Setting_up_email_templates#Set_up_Email_Templates_using_admin_console

To make changes to the DB, we would need to created a script that would attach to your DB service in DF. The script can be fired when a particular action is performed (in your case, a password reset). We have a great guide here - https://guide.dreamfactory.com/docs/chapter06.html#modifying-existing-api-endpoint-logic

Let us know if you have any more questions

Hi!

my question is more about if there is a way to call user/password on 2 different scenarios; the first one send an email A (with the default template, info, link and code ) and the second one, send an email B (with diferent template, information but also the link and code as well). There is a way to achieve this?

Greetings,

Yes, absolutely . You can write a script to call the endpoints on two scenarios.

I’ve already have 2 scripts, in both i call to user/password?reset=true and send the same email with the default template. how can i specify to the 2nd script to send the forgot email but with a different template?

Correct. In the second script, you would again call the password reset/forgot email endpoint and send the new template.

To reset user/password:
POST user/password?reset=true
{"email":"youremail@yourdomain.com"}

OR
POST user/password
{"email":"youremail@yourdomain.com","reset":true}

To create a new template

POST http://{url}/api/v2/system/email_template

Request Body:

{
    "resource": [
        {
            "name": "",
            "description": "",
            "to": "",
            "cc": "",
            "bcc": "",
            "subject": "",
            "body_text": "",
            "body_html": "",
            "from_name": "",
            "from_email": "",
            "reply_to_name": "",
            "reply_to_email": ""
        }
    ]
}

In other words, once you have a new template setup, you can simply call that template from your second script using the name of the template - /api/v2/system/email_template_name

Refer this link to learn more about email templates: http://wiki.dreamfactory.com/DreamFactory/Tutorials/Setting_up_email_templates#Set_up_Email_Templates_using_admin_console

Hi, is there a way i can build my own password reset script?

Yes, you can. Simple use a scripting service (REF) and call this endpoint in your script

To reset user/password:
POST user/password?reset=true
{"email":"youremail@yourdomain.com"}

OR
POST user/password
{"email":"youremail@yourdomain.com","reset":true}