zapadi / redmine-net-api

.Net API for Redmine bug/task management systems.
Apache License 2.0
169 stars 85 forks source link

Unable to deserialize Redmine User with enabled two-factor authentication #324

Closed TihomirStoyanov closed 1 year ago

TihomirStoyanov commented 1 year ago

Redmine server version: 4.2.8.stable Issue exists with redmine-net-api 4.30 and 4.6.0 Serialization type: xml

Enable two-factor authentication for some user, then try to get users from redmine. The xml for the user looks like:

<user>
    <id>13</id>
    <login>test.test</login>
    <admin>false</admin>
    <firstname>Test</firstname>
    <lastname>Test</lastname>
    <mail>test.test@company.com</mail>
    <created_on>2022-11-29T08:45:03Z</created_on>
    <updated_on>2023-02-09T17:34:35Z</updated_on>
    <last_login_on>2023-05-17T10:29:31Z</last_login_on>
    <passwd_changed_on/>
    <twofa_scheme>totp</twofa_scheme>
    <custom_fields type="array">
      <custom_field id="11" name="Custom Field 1">
        <value>Yes</value>
      </custom_field>
      <custom_field id="12" name="Custom Field 2">
        <value/>
      </custom_field>
      <custom_field id="13" name="Custom Field 3">
        <value>No</value>
      </custom_field>
      <custom_field id="14" name="Custom Field 4">
        <value/>
      </custom_field>
    </custom_fields>
  </user>

when two-factor authentication is disabled the element is: <twofa_scheme/>

Here is the exception from the code: DeserializeRedmineUserException

Suggested change in: https://github.com/zapadi/redmine-net-api/blob/master/src/redmine-net-api/Types/User.cs#L190

change reader.ReadContentAsString() to reader.ReadElementContentAsString()

zapadi commented 1 year ago

Thanks