简体   繁体   中英

Auth0: How to update user_metadata from rules?

It is possible to update user_metadata from rules? I know. it an be done through rest calls passing access token shown here , but is it possible to do it through the rules?

If address property needs to be added to user_metadata, then

const updateUsermetadata = (session) => {
    user.user_metadata = user.user_metadata || {};
    if (user.user_metadata.address !== null && user.user_metadata.address !== undefined) {} else {
      user.user_metadata.address = user.user_metadata.address || {};
      user.user_metadata.address = "123 blvd, NYC 11011";
    }

    // persist the user_metadata update
    auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
      .then(function () {
        callback(null, user, context);
      })
      .catch(function (err) {
        callback(err);
      });
 };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM