Skip to content

Commit

Permalink
Merge pull request #9533 from sstrigler/EMQX-8373-5-0-refactor-put-us…
Browse files Browse the repository at this point in the history
…ers-username-change-pwd

refactor: use POST not PUT for `/users/{name}/change_pwd`
  • Loading branch information
sstrigler committed Dec 13, 2022
2 parents 1ddfa92 + 7bdb029 commit 948d417
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/emqx_dashboard/src/emqx_dashboard_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_dashboard/test/emqx_dashboard_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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">>,
Expand Down
2 changes: 2 additions & 0 deletions changes/v5.0.13-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions changes/v5.0.13-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 修复

0 comments on commit 948d417

Please sign in to comment.