Closed pythonistastic closed 3 years ago
I suggest you post your Parse Server configuration to get more specific support. The feature requires an email adapter to be set up with Parse Server.
For now I am closing this as it does not seem to be a Parse Server issue.
For help with Parse Server, here are some resources you can try:
Feel free to comment if you have any questions and we can re-open this issue.
I suggest you post your Parse Server configuration to get more specific support. The feature requires an email adapter to be set up with Parse Server.
For now I am closing this as it does not seem to be a Parse Server issue.
For help with Parse Server, here are some resources you can try:
* For code-level questions we recommend Stack Overflow using the [parse-platform](https://stackoverflow.com/questions/tagged/parse-platform) tag. * For network and server questions we recommend ServerFault using the [parse-server](https://serverfault.com/questions/tagged/parse-server) tag * For questions that are not appropriate for the above mentioned sites we recommend our [community forum](https://community.parseplatform.org).
Feel free to comment if you have any questions and we can re-open this issue.
Hey @mtrezza , I have been reading about the email adapter and it looks like its already there in the server in the "/opt/bitnami/parse/node_modules/@parse/simple-mailgun-adapter" , and according to that I have edited my server.js file to be as follow:
const express = require('express');
const { ParseServer } = require('parse-server');
const api = new ParseServer({ databaseURI: 'mongodb://bn_parse:4Wbyxhl3rt@127.0.0.1:27017/bitnami_parse', appId: 'myappID', masterKey: 'mydashboardkey', serverURL: 'http://server_public_ip/parse',
verifyUserEmails: true,
// if
verifyUserEmails
istrue
and // ifemailVerifyTokenValidityDuration
isundefined
then // email verify token never expires // else // email verify token expires afteremailVerifyTokenValidityDuration
// //emailVerifyTokenValidityDuration
defaults toundefined
// // email verify token below expires in 2 hours (= 2 60 60 == 7200 seconds) emailVerifyTokenValidityDuration: 2 60 60, // in seconds (2 hours = 7200 seconds)// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email // set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified preventLoginWithUnverifiedEmail: false, // defaults to false
// The public URL of your app. // This will appear in the link that is used to verify email addresses and reset passwords. // Set the mount path as it is in serverURL publicServerURL: 'http://server_public_ip/parse', // Your apps name. This will appear in the subject and body of the emails that are sent. appName: 'parse-server', // The email adapter emailAdapter: { module: '@parse/simple-mailgun-adapter', options: { // The address that your emails come from fromAddress: 'parse@sandbox7232f7fc61ebfvbwetbrh7.mailgun.org', // Your domain from mailgun.com domain: 'sandbox7232f7fc61ebfvbwetbrh7.mailgun.org', // Your API key from mailgun.com apiKey: 'sandbox_api_key' } },
});
const app = express(); app.use('/parse', api);
const port = 1338; const httpServer = require('http').createServer(app);
httpServer.listen(port, () => { console.log(
parse-server running on port: ${port}
); });
So that is my server.js file in which I have read in documentations where to place the part of emailAdapter.
Can you help me with this one please?
I would just note at this point that the simple-mailgun-adapter is about to be deprecated. As alternative, there are a number of community provided email adapters. I suggest to try out the API Mail Adapter which has a demo script that allows you to verify whether your Mailgun configuration is correct, see the docs.
This section is for Parse Server issues, for further support please use the links posted above.
Hey @mtrezza , thank you for suggesting the API Mail Adapter, I have tried to lunch the demo script it failed at first with an error, digging around I have done a few changes in the script as per the instructions update in mailgun.js (https://github.com/mailgun/mailgun-js) the demo script (which is demo/index.js) is missing two lines at the beginning:
const formData = require('form-data');
const mailgun = new Mailgun(formData);
after implementing the changes the demo fired successfully, but once I have implemented the changes to the configuration file of the server it still generates the same error line as before. Anyway thank you for the suggestion, I will try to go around the server files to find a solution.
These lines should only be needed if you upgraded the maingun adapter to 3.x; 2.x doesn't require these lines.
Edit: Apologies, I just noticed that the adapter dependency is already on 3.x. In that you are correct, there is a PR already to correct the example.
Did you install the adapter with npm i
? Maybe you want to post your current Parse Server config.
No I actually used npm install to get the mailgun.js.
yea actually this is the configuration file content:
const express = require('express'); const { ParseServer } = require('parse-server');
const Mailgun = require('../node/lib/node_modules/mailgun.js/dist/mailgun.js'); const formData = require('../node/lib/node_modules/parse-server-api-mail-adapter/demo/form-data'); const mailgun = new Mailgun(formData);
const mailgunClient = mailgun.client({ username: 'api', key: 'mailgun_key' }); const mailgunDomain = 'sandbox7232f7fc61eb4df1a58d0944389.mailgun.org';
const api = new ParseServer({ databaseURI: 'mongodb://bn_parse:3Ergxhl4pr@127.0.0.1:27017/bitnami_parse', appId: 'myappID', masterKey: 'myMasterKey', serverURL: 'http://public_ip/parse', appName: 'app name', publicServerURL: 'http://public_ip/parse', emailAdapter: { module: '../node/lib/node_modules/parse-server-api-mail-adapter', options: { // The email address from which emails are sent. sender: 'the_sender_email', // The email templates. templates: { // The template used by Parse Server to send an email for password // reset; this is a reserved template name. passwordResetEmail: { subjectPath: './templates/password_reset_email_subject.txt'), textPath: './templates/password_reset_email.txt'), htmlPath: './templates/password_reset_email.html') }, // The template used by Parse Server to send an email for email // address verification; this is a reserved template name. verificationEmail: { subjectPath: './templates/verification_email_subject.txt'), textPath: './templates/verification_email.txt'), htmlPath: './templates/verification_email.html') }, // A custom email template that can be used when sending emails // from Cloud Code; the template name can be chosen freely; it // is possible to add various custom templates. customEmail: { subjectPath: './templates/custom_email_subject.txt'), textPath: './templates/custom_email.txt'), htmlPath: './templates/custom_email.html'), // Placeholders are filled into the template file contents. // For example, the placeholder
{{appName}}
in the email // will be replaced the value defined here. placeholders: { appName: "ExampleApp" }, // Extras to add to the email payload that is accessible in the //apiCallback
. extra: { replyTo: 'no-reply@example.com' }, // A callback that makes the Parse User accessible and allows // to return user-customized placeholders that will override // the default template placeholders. It also makes the user // locale accessible, if it was returned by thelocaleCallback
, // and the current placeholders that will be augmented. placeholderCallback: async ({ user, locale, placeholders }) => { return { phone: user.get('phone'); }; }, // A callback that makes the Parse User accessible and allows // to return the locale of the user for template localization. localeCallback: async (user) => { return user.get('locale'); } } }, // The asynchronous callback that contains the composed email payload to // be passed on to an 3rd party API and optional meta data. The payload // may need to be converted specifically for the API; conversion for // common APIs is conveniently available in theApiPayloadConverter
. // Below is an example for the Mailgun client. apiCallback: async ({ payload, locale }) => { const mailgunPayload = ApiPayloadConverter.mailgun(payload); await mailgunClient.messages.create(mailgunDomain, mailgunPayload); } } }}); const app = express(); app.use('/parse', api);
const port = 1338; const httpServer = require('http').createServer(app);
httpServer.listen(port, () => { console.log(
parse-server running on port: ${port}
); });
My first guess would be to check the paths, it should work with a simple require('mailgun.js')
.
Also, the module should be without path, see the docs:
module: 'parse-server-api-mail-adapter',
Can you share the package.json?
I will try that simplifying the paths and changing the module.
The following is the content of package.json that is located in the same directory of configuration file:
{ "name": "parse-dashboard", "parseDashboardFeatures": [ "Data Browser", "Cloud Code Viewer", "Cloud Code Jobs Viewer and Runner", "Parse Config", "REST API Console", "GraphQL API Console", "JS Custom Query Console", "Class Level Permissions Editor", "Pointer Permissions Editor", "Send Push Notifications", "Logs Viewer", "Push Status Page", "Relation Editor" ], "description": "The Parse Dashboard", "keywords": [ "parse", "dashboard" ], "homepage": "https://github.com/ParsePlatform/parse-dashboard", "bugs": "https://github.com/ParsePlatform/parse-dashboard/issues", "version": "2.1.0", "repository": { "type": "git", "url": "https://github.com/ParsePlatform/parse-dashboard" }, "license": "SEE LICENSE IN LICENSE", "files": [ "Parse-Dashboard", "bin", "README.md", "LICENSE" ], "dependencies": { "@babel/runtime": "7.8.7", "bcryptjs": "2.3.0", "body-parser": "1.19.0", "codemirror-graphql": "github:timsuchanek/codemirror-graphql#details-fix", "commander": "5.0.0", "connect-flash": "0.1.1", "cookie-session": "2.0.0-beta.3", "copy-to-clipboard": "^3.2.0", "create-react-class": "15.6.3", "csurf": "1.11.0", "express": "4.17.1", "graphql": "14.6.0", "graphql-playground-react": "1.7.20", "history": "4.10.1", "immutable": "4.0.0-rc.9", "immutable-devtools": "0.1.5", "js-beautify": "1.11.0", "json-file-plus": "3.2.0", "package-json": "6.5.0", "parse": "^2.12.0", "passport": "0.4.1", "passport-local": "1.0.0", "prismjs": "1.20.0", "prop-types": "15.7.2", "query-string": "6.11.1", "react": "16.13.1", "react-ace": "^8.0.0", "react-dnd": "10.0.2", "react-dnd-html5-backend": "10.0.2", "react-dom": "16.13.1", "react-helmet": "6.0.0", "react-json-view": "^1.19.1", "react-redux": "5.1.2", "react-router": "5.1.2", "react-router-dom": "5.1.2", "regenerator-runtime": "0.13.5", "semver": "7.3.2", "@parse/simple-mailgun-adapter": "^1.1.0" }, "devDependencies": { "@babel/core": "7.8.7", "@babel/plugin-proposal-decorators": "7.8.3", "@babel/plugin-transform-regenerator": "7.8.7", "@babel/plugin-transform-runtime": "7.8.3", "@babel/preset-env": "7.8.7", "@babel/preset-react": "7.8.3", "babel-eslint": "10.1.0", "babel-loader": "8.1.0", "babel-plugin-transform-object-rest-spread": "6.26.0", "core-js": "3.6.5", "cross-env": "7.0.2", "css-loader": "3.5.2", "eslint": "6.8.0", "eslint-plugin-jest": "23.8.2", "eslint-plugin-react": "7.19.0", "file-loader": "6.0.0", "http-server": "0.12.0", "jest": "24.8.0", "marked": "0.8.2", "node-sass": "^4.13.1", "null-loader": "^3.0.0", "parse-server": "github:parseplatform/parse-server#master", "path-to-regexp": "3.2.0", "puppeteer": "3.0.0", "react-test-renderer": "16.13.1", "request": "2.88.2", "request-promise": "4.2.5", "sass-loader": "8.0.0", "style-loader": "1.1.2", "svg-prep": "1.0.4", "webpack": "4.42.1", "webpack-cli": "3.3.10" }, "scripts": { "dev": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --devtool eval-source-map --progress --watch", "dashboard": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --progress --watch", "pig": "http-server ./PIG -p 4041 -s & webpack --config webpack/PIG.config.js --progress --watch", "build": "cross-env NODE_ENV=production webpack --config webpack/production.config.js && webpack --config webpack/PIG.config.js", "test": "cross-env NODE_PATH=./node_modules jest", "lint": "eslint . --ignore-path .gitignore --cache", "pretest": "npm run lint", "generate": "node scripts/generate.js", "prepare": "webpack --config webpack/publish.config.js --progress", "server": "node server.js", "start": "node ./Parse-Dashboard/index.js" }, "bin": { "parse-dashboard": "./bin/parse-dashboard" }, "engines": { "node": ">=8.9" }, "main": "Parse-Dashboard/app.js", "jest": { "roots": [ "src/lib" ], "transform": { ".*": "
/testing/preprocessor.js" }, "unmockedModulePathPatterns": [ "react", "react-dom", "react-addons-test-utils", "fbjs" ] } }
I think you shouldn't need any path in the module property, in fact I think that is not allowed. Parse Server uses an internal adapter loader and I think that is why the loading fails and no adapter is set. npm will take care of that, it should automatically load from node_modules dir.
Also, there is still a dependency on simple-mailgun-adapte instead of the api mail adapter. I suggest you follow the adapter docs step-by-step:
npm i parse-server-api-mail-adapter
If it still doesn't work, change module to parse-server-api-mail-adapter
Sure thing I will try out these suggestions and hopefully it works, Thanks a lot man really appreciate it
Hey @mtrezza , I have tried to do the two suggested points but unfortunately still the same error keeps showing up An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality. I have tried looking up the file that generates the error which is UsersRouter.js and tried to play with the variables in it feeding in those required variables manually the interesting thing was another error showed saying mail adapter is missing. So it looks like the server is not recognizing the mail adapter when I install it using the npm command, and I think the reason is related to this warning that shows when I install the mail adapter:
root@ip-172-32-33-209:/home/bitnami# npm i parse-server-api-mail-adapter npm WARN saveError ENOENT: no such file or directory, open '/home/bitnami/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/home/bitnami/package.json' npm WARN bitnami No description npm WARN bitnami No repository field. npm WARN bitnami No README data npm WARN bitnami No license field.
so the npm installation is not finding package.json in the directory. but then it creates a package-lock.json file.
You can try to get the configuration right on a local environment until it sends out a password reset email, ideally using the parse-server-example repo. When you know the config is right, you can try to deploy to a remote environment and get it to run there.
This way you separate mail adapter config issues from environment issues.
New Issue Checklist
Issue Description
I am building an android app and I am using Parse server through AWS EC2, so the issue is when I try to apply the method of Email verification and password reset as mentioned here: https://docs.parseplatform.org/android/guide/#resetting-passwords , and then run the app an error shows up in the logs
So I have done my reasearch over stackoverflow and almost everywhere and I have followed the instructions in this page: https://github.com/parse-community/parse-server#email-verification-and-password-reset , I have created a mailgun and using their sanbox domain and api, also I have edited the server.js file located in /opt/bitnami/parse-dashboard , and have tried to reboot the server using sudo reboot, but still no luck the same error keeps showing up
Steps to reproduce
Actual Outcome
Expected Outcome
Failing Test Case / Pull Request
Environment
Server
Database
Client
Logs