Repository navigation
Tips for implementing password reset? #99
Description
Activity
+1
Generally this has just a few parts:
- An express route or a cloud function to handle a password reset submission, which queries for a user matching the username/email. Generate a one-time random code and save it somewhere along with the user... Email the user, using some mail provider, with a link.
- An express route to handle the link, which takes the random code provided and searches for the user, validates it, and then presents them with the ability to provide a new password... Use the master key to override the password and save the user.
If you have further questions let me know..
Reacted by Alonso Vega, Jerad Maplethorpe, Cory Shaw and Larry MickieI have Xcode 7 IOS 9 Swift 2.1 project using Parse SDK, with already working signup email account activation ( email verification ) and reset password features. In the open source Parse Server, I don't see anywhere I can configure this email features when I migrate out of Parse hosting services. There seems no documentation about migration of this Parse hosted email feature anywhere either. What will happen to these existing hosted email features after migrating out of Parse to open source Parse Server hosted on AWS or Heroku as is? How can I configure to make these working again?
They are not yet implemented in
parse-serverso are currently unavailable until developed.@gfosco Sounds, good thanks for your hint
@gfosco would you say these are "going to come"? Like you did, for example, for push and dashboard.
@gfosco is this password reset not going to be added to the parse-server? all the code gen and user codes are the hardest part. Curious if your team will be sharing examples for this or anything besides your 2 sentences.
They are coming, as soon as the interface for mail adapters is nailed down. You can follow some discussion in #275. Look in the PRs and you'll see multiple competing implementations already.
I was able to the reset password use case to work with SimpleMailgunAdapter. I did have to debug some of the internals though.
This is the mailgun code:
var SimpleMailgunAdapter = require('parse-server/lib/Adapters/Email/SimpleMailgunAdapter');
var simpleMailgunAdapter = new SimpleMailgunAdapter({
apiKey: process.env.MAILGUN_KEY || '',
domain: process.env.DOMAIN || '',
fromAddress: process.env.MAILGUN_FROM_ADDRESS || ''
});The tricky part was learning that the following arguments must be passed to the ParseServer ctor, otherwise you'll get different levels of failures:
publicServerURL: process.env.PUBLIC_SERVER_URL || 'http://localhost:1337/parse'
appName: process.env.APP_NAME || '<your app name?'
emailAdapter: simpleMailgunAdapter
I set publicServerURL to be the same as serverURL. Didn't really understand the need for both but if you don't set the publicServerURL it all doesn't work.
Reacted by DpublicServerURL should be set when you deploy remotely to a full domain URL as he clients won't be able to access the serverURL if that one refers to locallhost
Reacted by ManuelIs there still an option to user some parse password reset web template, like it was before going open source? I don't no much about web pages, so it'll be great if there is some default page where the user can change password.
Is there a roadmap when password reset would be implemented in parse-server?
Reacted by Michael Bina, André Mafra, Hanno, TonyTang, Andrey Gordeev, Riccardo Bianchi, Pkmmte Xeleon, Abdennacer LACHIHEB, Javier, Jack Higgins and 12 moreThis is implemented and fully functional, as well as password reset pages etc..:
4 remaining items
Thanks for taking a look at it. I've been thinking all this morning about it and I think it's a possibility that I may not have either installed it to the right folder (I'm supposed to install " parse-server-simple-mailgun-adapter " directly into my "parse-server" folder correct?), or perhaps I did not put the code in the right index.js file.
Previously I've located my app, and found the index.js file for my app. So for example theres a folder called myAppFolder. Inside I see folders that read "ParseStarterProject-Swift", "ParseStarterProject", and "parse-server-example-master". In "parse-server-example-master", I see an index.js file and that was the index.js file I added the above code to.
But now I'm wondering if I should be editing the index.js file found in "parse-server" folder > "spec" folder > index.spec.js file?
Can anyone give me insight into the exact index.js file I should be editing?
you should not have the specs in your parse-server installation. How did you install parse-server? Did you use parse-server-example?
I did, back in January. I followed the migration guide.
ok, to install the mail adapter, did you run
npm install --save parse-server-simple-mailgun-adapterYes in this way:
"
Felecias-iMac:~ feleciacoleman$ cd parse-server
Felecias-iMac:parse-server feleciacoleman$ npm i parse-server-simple-mailgun-adapter
[email protected] /Users/feleciacoleman/parse-server
└── [email protected]Felecias-iMac:parse-server feleciacoleman$
"
it is correct to install this directly in the parse-server directory, yes?
And actually, after doing some digging it appears I might have installed parse-server from "https://github.com/parse-community/parse-server" as opposed to "https://github.com/parse-community/parse-server-example" ... that would explain why I have the spec folder :/
could that really be causing this problem? I am able to effectively run/view my parse-dashboard and have been for months.how did you install it? did you clone the repository and deploy that? Did you follow the installation instructions?
i ended up installing the parse server using homebrew. I followed those installation instructions as best as i could. I kept running into road blocks so I actually had to follow multiple different tutorials to get through all of the hurdles. It seemed that everything worked out because all of my data migrated and I was able to run the dashboard effectively, but by forgot password not working, now I'm wondering if I was wrong about thinking I installed it properly after all.
i ended up installing the parse server using homebrew
I'm not aware you can install parse-server with homebrew, there is plenty of documentation for installing and setting up, I'm not sure what steps your used to install therefore I can't say what's right or wrong...
$ brew search parse-server No formula found for "parse-server".Not even sure how you got there...
you are right, in my case I needed to do a few steps (installing node & mongodb) prior to installing parse server that i used homebrew for, then i cloned the parse directory.
I followed this tutorial here https://www.raywenderlich.com/146736/parse-server-tutorial-ios
What would help me most is giving insight into which folders things are supposed to be downloaded into. For instance, the parse server tutorial link above says this: "Next, in the root folder of the Parse project, open index.js and replace the default database string with your MongoDB database URI:
// Replace this
var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;// With this
var databaseUri = 'mongodb://:@ds017678.mlab.com:17678/tutorial-app';
This configures Parse Server to talk to your mLab database."If getting parse server installed required me to locate the root folder of my parse project and edit the index.js file in there, my thought was that that is also the folder where i need to install mailgun adapter and add the email adaptor options, however many posts on stackoverflow say that the file to where I edit the index.js and add the email adaptor options should be directly in the "parse-server" folder.
What im saying is that I believe it's possible that my mailgun adapter installation may not be installed in the right folder, or perhaps i have not edited the proper index.js file. I think this is a directory location issue and it would be more effective for me to know what is correct versus asking you to do the ungodly task of trying to undo what ive done wrong (cause it could be many different things as I'm a newbie).
thanks for spending time on this w me.
@FeleciaGenet I might be wrong here, but I think you're coming at this from a WordPress background or something of the sort which is why you're confused about the directory structures for installing modules/components of your app... Parse Server and other apps/frameworks built with the MEAN stack or NodeJS utilize NPM (the Node Package Manager) which automatically installs modules into the root directory of your project. By root directory, I mean the directory which you presumably setup as a repository in source control (Git, Mercurial, etc...) and it the place where your
node_modulesfolder and thepackage.jsonfile resides. From within that directory or any sub directory you can run thenpm install PACKAGE_NAME --savecommand from a terminal window and it will install the package into thenode_modulesfolder in a flat/de-nested way and update your package.json file to reflect the package being installed (assuming you have that--saveflag)... Essentially you should never have to go intonode_modules/parse-serverand run any installation commands or change code/configurations there. Due to the way that NodeJS's globalrequire('package-name')command works, theparse-servercode will be able to find and utilize theparse-server-simple-mailgun-adaptercode once you've installed both packages via NPM and you've configured the code in your app as the instructions indicate... It's basically safe to say that tampering with any of the code/folders within yournode_modulesfolder is a bad idea, especially if your app is in source control and might be shared with other developers as it is recommended that you ignore thenode_modulesfolder from source control (like add it to your .gitignore file) in MOST cases... So if another developer cloned your codebase they would have to reinstall the modules and wouldn't get any of the changes you made locally in the ignored folder.Please help reset user password!
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
verifyUserEmails: false, //depends on your needs, you can set it to false
emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
preventLoginWithUnverifiedEmail: false, // defaults to falsepublicServerURL: 'https://a.herokuapp.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'APP',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: '[email protected]',
// Your domain from mailgun.com
domain: 'https://api.mailgun.net/v2/mg.a.com/messages',
// Your API key from mailgun.com
apiKey: 'key-aaaaaaaaaaaa'
// Your API key from mailgun.com
}
},The server works perfectly(all data loaded as well)
Mailgun works perfectly(sending emails from terminal works like a charm)When I try to reset password I have in log:
2017-07-17T22:20:06.550173+00:00 heroku[router]: at=info method=POST path="/parse/requestPasswordReset" host=a.herokuapp.com request_id=ff60cd44-6557-464c-9f17-aaaaaaaaa fwd="12.345.678.90" dyno=web.1 connect=1ms service=77ms status=200 bytes=483 protocol=https
And nothing happenWhat I am doing wrong ?????
If I will remove the appName I will see in the log:
An appName, publicServerURL, and emailAdapter are required for password reset functionality.' } code=1, message=An appName, publicServerURL, and emailAdapter are required for password reset functionality.
If I will request reset for wrong user I will see in the log:
2017-07-17T22:27:23.340663+00:00 app[web.1]: message: 'No user found with email [email protected].' } code=205, message=No user found with email [email protected].
2017-07-17T22:27:23.349814+00:00 app[web.1]: [object Object]It is mean that everything is worked BUT IT IS NOT SENDING THE EMAIL
Thank you for response.@adamofsky did you able to sort this out, today I am in the same situation like yours.
MailAdapter works fine with terminal/nmp however not able to setup in my app for password reset.
Hi, I would like to look into implementing the password reset functionality. Any hints and tips for that?
Thanks!