Actions
Defect #28686
closed/users API does not accept boolean-like String values for generate_password
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
When creating a new user using the XML Rest API and the following XML, Redmine is not generating a new password.
<user>
<login>test</login>
<firstname>test</firstname>
<lastname>test</lastname>
<mail>test@example.org</mail>
<generate_password>true</generate_password>
<must_change_passwd>true</must_change_passwd>
</user>
The true value for must_change_passwd works as expected, the one for generate_password is ignored.
The reason for that is, that must_change_passwd is a proper database column and ActiveRecord will translate certain expected values to Boolean true. Among these are "1", "true", and true. In contrast generate_password is a virtual attribute, which is not backed by a database column. Redmine has its own code to handle the translation here. But this custom code only accepts "1" and true, i.e it's missing the "true" option.
The attached patch fixes this shortcoming by using ActiveRecord's translation method directly.
Files
Actions