Update email_verified on password reset

How can we set the email_verified to TRUE on successful password reset?
Can do this with a patch request to /aip/v2/users/{id}, but how to run this after successful reset?

:wave: @alex.kuttner

You could create a Rule to accomplish this. Are you using a custom database or Auth0? If you are using Auth0 databases this example code below, or you can grab it from our GitHub, will help you get the job done.

Do note that this will set email_verified to true only when the next successful login sequence happens after the password is reset.

function (user, context, callback) {
  var request = require('request@2.56.0');
  var userApiUrl = auth0.baseUrl + '/users/';
  
  if (context.connectionStrategy !== "auth0") {
    return callback(null, user, context);
  }

  if (!user.email_verified && user.last_password_reset) {
    request.patch({
      url: userApiUrl + user.user_id,
      headers: {
        Authorization: 'Bearer ' + auth0.accessToken
      },
      json: { "email_verified": true },
      timeout: 5000
    }, 
    function(err, response, body) {
      context.idToken.email_verified = true;

      return callback(null, user, context);
    });
  } else {
    return callback(null, user, context);
  }