HabitRPG / habitrpg-email-server

The server from which all HabitRPG's emails are sent
Other
11 stars 7 forks source link

Restore password. Bug, no documentation? #17

Closed sergey-prosvirnin closed 4 years ago

sergey-prosvirnin commented 4 years ago

Hi, I use habitica and habitrpg-email-server + Mandrill API. I want to do a password recovery via a link and have created a corresponding template for that.

image

But when I try to click the link I get a 404 although this URL is sent in the habitrpg-email-server request. What could be the error?

image image. image

Also, it should be noted that the request to send an email is sent through the habitrpg-email-server, is only made when in the file \website\server\libs\email.js check for Boolean value IS_PROD, because the token "IS_PROD": "true" in the file config.json is not read and by default is always false. How do I fix this unusual behavior?

image

paglias commented 4 years ago

Also, it should be noted that the request to send an email is sent through the habitrpg-email-server, is only made when in the file \website\server\libs\email.js check for Boolean value IS_PROD, because the token "IS_PROD": "true" in the file config.json is not read and by default is always false. How do I fix this unusual behavior?

The IS_PROD env var is defined not in the config.json file but based on the value of NODE_ENV here https://github.com/HabitRPG/habitica/blob/f8bab04a0e66a819f6d7ca5b210d27d991446bf3/website/server/libs/setupNconf.js#L16

Regarding the issue itself it's really difficult to understand what is not working without seeing the logs but it's working on habitica.com, for example with this url http://habitica.com/static/user/auth/local/reset-password-set-new-one?code=aa

sergey-prosvirnin commented 4 years ago

At first, I was confused by this line, similar ones are used to obtain token values from config.json :)

image

Tell me what kind of logs you need and I will put them out. The backend and mail server logs are almost empty.

Can you tell me what the correct BASE_URL habitica token value should be if I use a domain and NGINX as a reverse proxy? For example http://mydomain.com, https://mydomain.com, http://localhost:3000 or https://localhost:3000? As far as I understand, this token also forms a link to reset the password. Maybe that's just it?

Also, it should be noted that the request to send an email is sent through the habitrpg-email-server, is only made when in the file \website\server\libs\email.js check for Boolean value IS_PROD, because the token "IS_PROD": "true" in the file config.json is not read and by default is always false. How do I fix this unusual behavior?

The IS_PROD env var is defined not in the config.json file but based on the value of NODE_ENV here https://github.com/HabitRPG/habitica/blob/f8bab04a0e66a819f6d7ca5b210d27d991446bf3/website/server/libs/setupNconf.js#L16

Regarding the issue itself it's really difficult to understand what is not working without seeing the logs but it's working on habitica.com, for example with this url http://habitica.com/static/user/auth/local/reset-password-set-new-one?code=aa

sergey-prosvirnin commented 4 years ago

Now I realized that I need to specify a domain. Then the question is, what protocol should I indicate in my case?

sergey-prosvirnin commented 4 years ago

Logs all server (I use pm2 process manager).

logs.zip

Request from habitrpg-email-server to Mandrill API.

https://gist.github.com/sergey-prosvirnin/420d707532a3dd79d52ee5067f1bba57

P.S. I set the production environment variable through the command _export NODEENV=production and sending mail stopped working.

paglias commented 4 years ago

The BASE_URL should be with https if your deployment supports https, with http if it doesn't. As far as Ngnix we don't use that so I can't really help, I'm sorry.

P.S. I set the production environment variable through the command export NODE_ENV=production and sending mail stopped working.

Again it's a bit difficult to understand what the problem is with so little information, but we run with NODE_ENV set to production and emails are working correctly, I would put console.log or debug statements and see where it breaks.

Finally, I'm sorry but we don't use Github for support tickets, in particular we don't support production deployments of the codebase as we use our own solution and there are no docs around it. I would suggest to try posting in the Aspiring Blacksmiths guild on Habitica