Automatic Password Expiry after N days || Upon pwd expiry route user to password reset page


I am trying to achieve to set password expiry for Auth0 users and upon expiry display, a proper error message saying your password expired and click here to reset your password .

for which I am trying to use “Check Last Password Reset” RULE.
However, using this rule it does not actually expire the password instead it is throwing 500 Internal server error on Assertion consumer service url POST request and in SAML Response it is returning the message we wrote in the rule.
also, I can see it is sowing as successful last login.

basically, that rule is sending incorrect SAML to the application.

Here is the Javascript in the rule.

function checkLastPasswordReset(user, context, callback) {
function daydiff(first, second) {
return (second - first) / (1000 * 60 * 60 * 24);

const last_password_change = user.last_password_reset || user.created_at;

if (daydiff(new Date(last_password_change), new Date()) > 1) {
return callback(new UnauthorizedError(“Your Password has expired… please reset”));
callback(null, user, context);

Here is the sample SAML Response.

<samlp:Response xmlns:samlp=“urn:oasis:names:tc:SAML:2.0:protocol”
<saml:Issuer xmlns:saml=“urn:oasis:names:tc:SAML:2.0:assertion”></saml:Issuer>
<samlp:StatusCode Value=“urn:oasis:names:tc:SAML:2.0:status:Responder” />
<samlp:StatusMessage Value=“Your Password has expired… please reset” />

can you guide me to customize this javascript… actually Auth0 to display " Password Expired Message" and provide link to reset the password.