refactor: use POST not PUT for `/users/{name}/change_pwd`

This commit is contained in:
Stefan Strigler 2022-12-08 14:46:51 +01:00
parent 1ddfa92119
commit 7bdb029745
4 changed files with 7 additions and 3 deletions

View File

@ -147,7 +147,7 @@ schema("/users/:username") ->
schema("/users/:username/change_pwd") ->
#{
'operationId' => change_pwd,
put => #{
post => #{
tags => [<<"dashboard">>],
desc => ?DESC(change_pwd_api),
parameters => fields([username_in_path]),
@ -324,7 +324,7 @@ is_self_auth_token(Username, Token) ->
false
end.
change_pwd(put, #{bindings := #{username := Username}, body := Params}) ->
change_pwd(post, #{bindings := #{username := Username}, body := Params}) ->
LogMeta = #{msg => "Dashboard change password", username => Username},
OldPwd = maps:get(<<"old_pwd">>, Params),
NewPwd = maps:get(<<"new_pwd">>, Params),

View File

@ -141,7 +141,7 @@ t_rest_api(_Config) ->
}),
{ok, 204, _} = http_delete(["users", "usera"]),
{ok, 404, _} = http_delete(["users", "usera"]),
{ok, 204, _} = http_put(
{ok, 204, _} = http_post(
["users", "admin", "change_pwd"],
#{
<<"old_pwd">> => <<"public">>,

View File

@ -8,4 +8,6 @@
- Refactor: move `/mqtt/sys_topics` to generic `/configs/sys_topics` [#9511](https://github.com/emqx/emqx/pull/9511).
- Refactor: use `POST` not `PUT` for `/users/{name}/change_pwd` [#9533](https://github.com/emqx/emqx/pull/9533).
## Bug fixes

View File

@ -8,4 +8,6 @@
- 重构:删除 `/mqtt/sys_topics` 接口,用户可以使用通用的 `/configs/sys_topics` 接口来更新该配置 [#9511](https://github.com/emqx/emqx/pull/9511)。
- 重构: `/users/{name}/change_pwd` 的请求方式从 `PUT` 改为了 `POST` [#9533](https://github.com/emqx/emqx/pull/9533)。
## 修复