プロジェクト

全般

プロフィール

Vote #80070

完了

make /my/account endpoint accessible through API

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
127
issue_org_id:
31399
author_id:
40856
assigned_to_id:
332
comments:
12
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

This would allow a user to update their account info through an external app. Currently admin privileges are required to change i.e. a user's name through the /users API.


journals

--------------------------------------------------------------------------------
Setting the target version to 4.1.0.
--------------------------------------------------------------------------------
I have tested the patch and found that the endpoint behaves the same for both POST and PUT requests. In other words, POST updates the account instead of creating an account.

IMHO, Redmine should not respond to POST API requests. Since users think that POST requests are used to create an object, admin may accidentally update their own account when trying to create a new account (of course, they should be more carefully).

What are your thoughts on that?

--------------------------------------------------------------------------------
Yes, the thought that POST is not really nice there crossed my mind, but in order to keep the patch as small as possible I sticked to it since that is what the web form uses as well. If we change the API method to PUT, I would vote for changing the method used by the /my/account form to PUT, as well. What do you think?
--------------------------------------------------------------------------------
Jens Krämer wrote:
> If we change the API method to PUT, I would vote for changing the method used by the /my/account form to PUT, as well. What do you think?

Sounds nice, it makes things consistent. I am in favor of it.

--------------------------------------------------------------------------------
OK, then I will come up with a patch for that :)
--------------------------------------------------------------------------------
here's a second patch which changes the HTML form method to @PUT@ and removes support for @POST@ on that endpoint.
--------------------------------------------------------------------------------
Thank you for updating the patch but some tests fail after applying the second patch. Could you look into these errors?

<pre>
Failure:
SudoModeTest#test_update_email_address [/Users/maeda/redmines/trunk/test/integration/sudo_mode_test.rb:153]:
Expected response to be a <2XX: success>, but was a <404: Not Found>

bin/rails test test/integration/sudo_mode_test.rb:147
</pre>

<pre>
Failure:
RoutingMyTest#test_my [/Users/maeda/redmines/trunk/test/test_helper.rb:296]:
No route matches "/my/account"

bin/rails test test/integration/routing/my_test.rb:23
</pre>
--------------------------------------------------------------------------------
Indeed there was a bug - I forgot to change the sudo mode requirement in the controller to @PUT@. I also changed the tests to do PUT requests now / expect PUT to be routed instead of POST.
--------------------------------------------------------------------------------
Committed the patch. Thank you for your contribution.

The API document should be updated later.
--------------------------------------------------------------------------------
Documentation to be added here [[Rest_MyAccount]].
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

duplicates,Closed,19301,Let non admin users update their account via the REST API

Admin Redmine さんが4年以上前に更新

  • カテゴリREST API_32 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0