wolfgangimig / itol

JOA based issue tracker for Microsoft Outlook
23 stars 6 forks source link

No custom fields if user isn't admin #48

Closed Sledav closed 8 years ago

Sledav commented 8 years ago

I use redmine 3.2.2 and AddIn 2.0.

log itol

2016-05-21 11:45:36 INFO com.wilutions.itol.db.HttpClient send GET http://g0411-001:88/redmine/custom_fields.json #-1
2016-05-21 11:45:36 INFO com.wilutions.itol.db.HttpClient send send failed, exception=java.io.IOException: Server returned HTTP response code: 403 for URL: http://g0411-001:88/redmine/custom_fields.json

log redmine

Started GET "/redmine/custom_fields.json" for 127.0.0.1 at 2016-05-21 11:45:36 +0300
Processing by CustomFieldsController#index as JSON
  Current user: Kolenchenko_SP (id=131)
Filter chain halted as :require_admin rendered or redirected
Completed 403 Forbidden in 5ms (ActiveRecord: 1.0ms)
wolfgangimig commented 8 years ago

Redmine does not return custom field definitions for non-admins. That's why the log message is printed as INFO and not as WARN or ERROR.

The custom fields have to be assigned to projects in IssueServiceImpl.js too. See line 12 and following lines:

    // TODO: Names of fields used in all projects:
    // Add one line for each field in format ... "fieldname" : true,
    var customFieldsInAllProjects = {
            "Text1 with leerzeichen" : true,
            "MultiList" : true,
            "Overtime Date" : true,
            "LongText1" : true,
    };

    // TODO: Field to project relationship.
    // Add one line for each relation in format ... "fieldname in projectname" : true,
    var mapCustomFieldsToProjects = {
            "field1 in project1" : true,
            "field2 in project1" : true,
            "field1 in project2" : true,
            "Float1 Fließkomma in project1" : true,
    };
Sledav commented 8 years ago

I added my custom fields in customFieldsInAllProjects and mapCustomFieldsToProjects, but no custom fields are available in Addin. redmine's log:

Started GET "/redmine/custom_fields.json" for 127.0.0.1 at 2016-05-23 10:19:49 +0300
Processing by CustomFieldsController#index as JSON
  Current user: Kolenchenko_SP (id=131)
Filter chain halted as :require_admin rendered or redirected
Completed 403 Forbidden in 38ms (ActiveRecord: 1.0ms)

FILES.zip

wolfgangimig commented 8 years ago

There is an error in the log file while evaluating the encoded description of the configuration project: "Illegal base64 character 3f". The reason might be the additional character \r after the marker

<pre>ENCRYPTED_DATA_BEGIN\r\n

In IssueServiceImpl.js, the marker is defined without a \r. Hence, it cannot be found in the description and the code uses the entire text which is not fully encoded. The additional \r might be added automatically, if your Redmine service runs on Windows.

Change the marker definition as follows in your IssueServiceImpl.js:

var ITOL_CONFIG_DESC_TAG_BEGIN = "<pre>ENCRYPTED_DATA_BEGIN\r\n";
var ITOL_CONFIG_DESC_TAG_END = "\r\nENCRYPTED_DATA_END</pre>";
Sledav commented 8 years ago

Thanks, now it's work!