【问题标题】:Update user password via REST Drupal 8.x通过 REST Drupal 8.x 更新用户密码
【发布时间】:2017-03-02 06:18:19
【问题描述】:

我正在使用 Drupal 8.3.x。

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

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

HTTP请求是这样的。

方法:

PATCH

标题:

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

正文:

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

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

【问题讨论】:

    标签: php rest drupal-8


    【解决方案1】:

    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"}
        ]
    }
    

    【讨论】:

    • 嘿,我已经测试过这个解决方案,它可以工作,但它实际上不需要现有密码,如果我只输入新密码,它仍然会更改它并且不会在实际密码。我知道这篇文章有点旧,但这是我唯一发现的,有没有更好的方法来做我正在寻找的事情?
    猜你喜欢
    • 2016-08-04
    • 2020-02-07
    • 2014-07-06
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多