# Custom password/reset service

**URL:** <https://community.dreamfactory.com/t/custom-password-reset-service/5184>\
**Category:** Server-Side Scripting\
**Created:** [May 28, 2020, 3:56am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184 "2020-05-28T03:56:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuchoRod](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@LuchoRod](https://community.dreamfactory.com/u/LuchoRod)\
**Post date:** [May 28, 2020, 3:56am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/1 "2020-05-28T03:56:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abhishek.pandey](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@abhishek.pandey](https://community.dreamfactory.com/u/abhishek.pandey)\
**Post date:** [May 28, 2020, 4:31pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/2 "2020-05-28T16:31:18Z")

</div>

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 - [https://wiki.dreamfactory.com/DreamFactory/Tutorials/Setting\_up\_email\_templates#Set\_up\_Email\_Templates\_using\_admin\_console](https://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](https://guide.dreamfactory.com/docs/chapter06.html#modifying-existing-api-endpoint-logic)

Let us know if you have any more questions

---

<div class="post-metadata">

**Author:** ![LuchoRod](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@LuchoRod](https://community.dreamfactory.com/u/LuchoRod)\
**Post date:** [May 28, 2020, 10:40pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/3 "2020-05-28T22:40:08Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![abhishek.pandey](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@abhishek.pandey](https://community.dreamfactory.com/u/abhishek.pandey)\
**Post date:** [May 28, 2020, 10:59pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/4 "2020-05-28T22:59:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LuchoRod](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@LuchoRod](https://community.dreamfactory.com/u/LuchoRod)\
**Post date:** [May 28, 2020, 11:13pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/5 "2020-05-28T23:13:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![abhishek.pandey](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@abhishek.pandey](https://community.dreamfactory.com/u/abhishek.pandey)\
**Post date:** [May 28, 2020, 11:29pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/6 "2020-05-28T23:29:21Z")

</div>

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: [Setting up email templates - DreamFactory](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Setting_up_email_templates#Set_up_Email_Templates_using_admin_console)

---

<div class="post-metadata">

**Author:** ![LuchoRod](https://avatars.discourse-cdn.com/v4/letter/l/50afbb/32.png) [@LuchoRod](https://community.dreamfactory.com/u/LuchoRod)\
**Post date:** [June 3, 2020, 1:24am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/7 "2020-06-03T01:24:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abhishek.pandey](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@abhishek.pandey](https://community.dreamfactory.com/u/abhishek.pandey)\
**Post date:** [June 5, 2020, 8:19pm UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/8 "2020-06-05T20:19:54Z")

</div>

Yes, you can. Simple use a scripting service ([REF](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Custom_scripting_service_example)) 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}`

---

<div class="post-metadata">

**Author:** ![kwlayman](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@kwlayman](https://community.dreamfactory.com/u/kwlayman)\
**Post date:** [December 23, 2021, 10:21am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/9 "2021-12-23T10:21:43Z")

</div>

> [@abhishek.pandey](#):
>
> 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

I can’t figure out how to “simply call” or specify the template used by the user/password?reset api other than changing it via the Admin UI, can someone please give me an example of how to do it?

Same for passing in values for the reply\_to\_email field, is there anyway to set it dynamically in the reset function?

I have tried passing in the template name as shown in examples for the email service, and values for reply\_to\_email, but nothing works.

---

<div class="post-metadata">

**Author:** ![Thomasx](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@Thomasx](https://community.dreamfactory.com/u/Thomasx)\
**Post date:** [October 16, 2022, 8:25am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/10 "2022-10-16T08:25:03Z")

</div>

Hey,

Thanks for sharing

{  
“resource”: [  
{  
“name”: “”,  
“description”: “”,  
“to”: “”,  
“cc”: “”,  
“bcc”: “”,  
“subject”: “”,  
“body\_text”: “”,  
“body\_html”: “”,  
“from\_name”: “”,  
“from\_email”: “”,  
“reply\_to\_name”: “”,  
“reply\_to\_email”: “”  
}  
]  
}

It[’](https://whatslinkhub.com/)s perfectly working for me.

---

<div class="post-metadata">

**Author:** ![Thomasx](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@Thomasx](https://community.dreamfactory.com/u/Thomasx)\
**Post date:** [March 21, 2023, 11:59am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/11 "2023-03-21T11:59:42Z")

</div>

I’ve followed these: [Custom scripting service example - DreamFactory](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Custom_scripting_service_example) and found [i](https://activewhatslink.com/)f helpful.

---

<div class="post-metadata">

**Author:** ![sparkles](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/sparkles/32/1385_2.png) [@sparkles](https://community.dreamfactory.com/u/sparkles)\
**Post date:** [July 2, 2024, 6:48am UTC](https://community.dreamfactory.com/t/custom-password-reset-service/5184/12 "2024-07-02T06:48:12Z")

</div>

Yes you can easily use scripting service.
