# Setting temporary password on the server-side, user prompted to reset password upon login w/ temp password

**URL:** <https://community.auth0.com/t/setting-temporary-password-on-the-server-side-user-prompted-to-reset-password-upon-login-w-temp-password/73068>\
**Category:** Get Help\
**Tags:** rules, auth0\
**Created:** [November 12, 2021, 7:00pm UTC](https://community.auth0.com/t/setting-temporary-password-on-the-server-side-user-prompted-to-reset-password-upon-login-w-temp-password/73068 "2021-11-12T19:00:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jenna.Horrall](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jenna.horrall/32/32971_2.png) [@Jenna.Horrall](https://community.auth0.com/u/Jenna.Horrall)\
**Post date:** [November 12, 2021, 7:00pm UTC](https://community.auth0.com/t/setting-temporary-password-on-the-server-side-user-prompted-to-reset-password-upon-login-w-temp-password/73068/1 "2021-11-12T19:00:16Z")

</div>

Trying to create a flow such that:

1. user’s password is set to a temporary password on the server-side
2. user logs in with temporary password and is redirected to a reset password screen forcing them to reset upon login

Is this possible? I’ve already set the user’s password to a random generated string on the server-side, but I don’t know where to go from there. I’ve been looking into actions/hooks but I don’t know if those will apply for this specific case, because I only want the user to be redirected to reset their password if they enter in the temporary password that was requested on the server-side.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 12, 2021, 11:45pm UTC](https://community.auth0.com/t/setting-temporary-password-on-the-server-side-user-prompted-to-reset-password-upon-login-w-temp-password/73068/3 "2021-11-12T23:45:38Z")

</div>

Hi @Jenna.Horrall,

Welcome to the Auth0 Community!

I understand that you are trying to create a flow to direct newly created users to set a new password.

First, have you taken a look at the [Send Email Invitations for Application Sign Up](https://auth0.com/docs/brand-and-customize/email/send-email-invitations-for-application-signup) approach, which repurposes a change password link as an invitation?

Not only will this simplify the need of programmatically generating a user’s password, but will reduce the overall complexity and improve the UX.

> [@Jenna.Horrall](#):
>
> Is this possible?

It is possible, however, there isn’t an OOTB solution to do this. You’ll need to use a [Post-Login Action](https://auth0.com/docs/actions/triggers/post-login) with the Management API.

Note that whenever a user is created, the `last_password_reset` attribute is NULL. Therefore you can check `if(!event.user.last_password_reset)` is true in your post-login action and implement your logic to direct your users to reset their passwords.

In your Post Login Action script, do something like the following:

- If the user has not reset their password previously, then create a password change URL with the Management API ([https://auth0.github.io/node-auth0/module-management.ManagementClient.html#createPasswordChangeTicket](https://auth0.github.io/node-auth0/module-management.ManagementClient.html#createPasswordChangeTicket))
- Then redirect the user to the password change URL ([Redirect with Actions](https://auth0.com/docs/actions/triggers/post-login/redirect-with-actions))

After the user changes their password, this Action will not trigger again.

For more details read our [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947).

Please let me know how this goes for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 27, 2021, 11:46pm UTC](https://community.auth0.com/t/setting-temporary-password-on-the-server-side-user-prompted-to-reset-password-upon-login-w-temp-password/73068/4 "2021-11-27T23:46:17Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
