polonel / trudesk

:coffee: :seedling: Trudesk is an open-source help desk/ticketing solution.
http://trudesk.io
Other
1.31k stars 442 forks source link

Fix createUserFromEmail where email would not contain username and fullname #553

Closed mrt-prodz closed 2 years ago

mrt-prodz commented 2 years ago

Patch to fix issue #545 where a user created from email will fail to receive credentials in the confirmation mail. Handlebars seems to have an issue with accessing properties not being owned by its parent :

Handlebars: Access has been denied to resolve the property "fullname" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "username" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

I couldn't figure a way to keep the template using user.username so I made a copy of these properties in dataObject and replaced these variables in the mail template.

I kept the original user: savedUser in dataObject just in case the callback was using it later to avoid breaking anything :

https://github.com/polonel/trudesk/blob/5bbc42395de7d2589daa97d6837500826448ac11/src/models/user.js#L599

polonel commented 2 years ago

:tada: This PR is included in version 1.2.6 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: