Score:0

How can I allow users to change their email addresses without a password with JSON:API?

cn flag

I have an Ionic React app and I want to allow users to change their email addresses.

However, when I try to change the email address in a PATCH request, I get the following error:

{
   "jsonapi":{
      "version":"1.0",
      "meta":{
         "links":{
            "self":{
               "href":"http:\/\/jsonapi.org\/format\/1.0\/"
            }
         }
      }
   },
   "errors":[
      {
         "title":"Unprocessable Entity",
         "status":"422",
         "detail":"mail: \u300c\u30e1\u5fc5\u9808\u3067\u3059\u3002",
         "source":{
            "pointer":"\/data\/attributes\/mail"
         }
      },
      {
         "title":"Unprocessable Entity",
         "status":"422",
         "detail":"mail: Your current password is missing or incorrect; it\u0027s required to change the \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9.",
         "source":{
            "pointer":"\/data\/attributes\/mail"
         }
      }
   ]
}

This doesn't really make sense because the user already has a JWT to authenticate.

I found this drupal.org issue that has been marked as fixed, but this is just how to provide the current password to update the email address.

Instead, I would like to use the JWT or some other means to easily update the email address without inputting the password again.

The Nocurrent Pass module disables the password check when changing one's email address or password, which is what I want, but it does so by means of hook_form_alter(), which means it doesn't remove the check for JSON:API.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.