php - 通过 REST Drupal 8.x 更新用户密码

标签 php rest drupal-8

我正在使用 Drupal 8.3.x。

简单的要求就像,用户需要通过输入他的旧密码和新密码来更新他的密码。

通过谷歌我找到了this link并使用它,但我不明白如何发送新密码?

HTTP请求是这样的

方法:

PATCH

标题:

Authorization:Bearer <token>
Content-Type:application/hal+json

正文:

{
    "_links": {
        "type": {
            "href": "{domain}/rest/type/user/user"
        }
    },
    "pass": [
        {"existing":"testpass"}
    ]
}

现在如何在这里设置新密码?

最佳答案

Analogously更新邮件操作

{
 "_links": {
   "type": {
     "href": "{domain}/rest/type/user/user"
   }
 },
 "pass":[{"existing":"testpass"}],
 "mail":{
   "value":"updatedtestuser@mailserver.com"
 }
}

应该是这样的

{
    "_links": {
        "type": {
            "href": "{domain}/rest/type/user/user"
        }
    },
    "pass": [
        {"existing":"testpass", "value": "newpass"}
    ]
}

关于php - 通过 REST Drupal 8.x 更新用户密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42548132/

相关文章:

javascript - 开 Jest mock promise 方法调用错误次数

rest - 创建我自己的自定义 header 以用于版本控制 REST API

drupal-8 - 如何在 Drupal 8 中获取翻译内容的链接

php - 我该如何优化这个 MySQL 查询?

php - 德行 2 更改语言 native

php - 如何通过 PHP 中的 Web 服务发送/获取文件

node.js - Rest API Kafka 流

php - 如何避免字符串中的 '&' 运算符

ajax - 如何在不使用链接的情况下在 Drupal 8 中打开模态?

drupal - 如何在 Drupal 8 功能测试中导入配置同步文件?