Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tips for implementing password reset? #99

Closed
tamarabernad opened this issue Jan 31, 2016 · 31 comments
Closed

Tips for implementing password reset? #99

tamarabernad opened this issue Jan 31, 2016 · 31 comments

Comments

@tamarabernad
Copy link

Hi, I would like to look into implementing the password reset functionality. Any hints and tips for that?
Thanks!

@yamill
Copy link

yamill commented Jan 31, 2016

+1

@gfosco
Copy link
Contributor

gfosco commented Feb 1, 2016

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..

@gfosco gfosco added the question label Feb 1, 2016
@barcodehawk
Copy link

I 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?

@gfosco
Copy link
Contributor

gfosco commented Feb 1, 2016

They are not yet implemented in parse-server so are currently unavailable until developed.

@tamarabernad
Copy link
Author

@gfosco Sounds, good thanks for your hint

@natario1
Copy link

natario1 commented Feb 1, 2016

@gfosco would you say these are "going to come"? Like you did, for example, for push and dashboard.

@corbanb
Copy link
Contributor

corbanb commented Feb 16, 2016

@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.

@gfosco
Copy link
Contributor

gfosco commented Feb 16, 2016

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.

@gfosco gfosco closed this as completed Feb 16, 2016
@seryoni
Copy link

seryoni commented Mar 27, 2016

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.

@flovilmart
Copy link
Contributor

publicServerURL 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

@klemenzagar91
Copy link

Is 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.

@otmezger
Copy link

otmezger commented Aug 17, 2016

Is there a roadmap when password reset would be implemented in parse-server?

@flovilmart
Copy link
Contributor

This is implemented and fully functional, as well as password reset pages etc..:

@valdezm
Copy link

valdezm commented Feb 15, 2017

Awesome, yeah I see that now, Thanks @flovilmart I appreciate it! My mistake was that I didn't set the following correctly:
publicServerURL: 'https://example.com/parse',

That really should be specified more accurately to be:
publicServerURL: 'https://thestandaloneparseserverURL.com/parse',

I thought it was just what the companies website was, not the actual endpoint that has the form which exists on the ParseServer through that project....

Appreciate your help though, much appreciated!

BernhardHarrer pushed a commit to BernhardHarrer/parse-server that referenced this issue Feb 22, 2017
Updated README with a Swift Configuration exemple
@w3care25
Copy link

I am getting following error when trying to requestPasswordReset.
My Parse server version is : 1.0.0
{"level":"error","message":"Uncaught internal server error. [TypeError: promiseHandler(...).then is not a function] TypeError: promiseHandler(...).then is not a function\n at parse/node_modules/parse-server/lib/PromiseRouter.js:286:27\n

also email is not going.

@FeleciaGenet
Copy link

FeleciaGenet commented Jul 7, 2017

I feel I am so close to figuring this out but I must be missing something! I've obviously managed to migrate the database over, I've managed to even get the push notifications working and I am able to run parse server remotely on my mac, but i am stuck with the password reset functionality. Mailgun is installed on my heroku add ons and I have changed all of my DNS keys so my domain says "active" on Mailguns end.

On my desktop, I located my folder > found the parse-server-example-master > index.js

in index.js I have put the following code. perhaps I have not replaced a necessary key? For the sake of this discussion, everywhere where I have replaced the example keys with my own keys begins with "&" symbol.

After I replaced the following keys, I commit to my GItHub Desktop and Synced. The changes appear via my web github as expected. What am I doing wrong here?

Xcode console still prints "[Error]: An appName, publicServerURL, and emailAdapter are required for password reset functionality. (Code: 1, Version: 1.14.2)" when I tap the "forgot password" button i've created.

ANY HELP APPRECIATED!!!

  • Felecia

(index.js code below)

// Example express application adding the parse-server module to expose Parse
// compatible API routes.
//

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({

databaseURI: databaseUri || '&mongodb://heroku_abcdefghijklmnopqrxzy@abcdefghijklmnopqrxzy.mlab.com:00000/heroku_abcdefghijklmnopqrxzy',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '&abcdefghijklmnopqrxzy',
masterKey: process.env.MASTER_KEY || '&abcdefghijklmnopqrxzy', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || '&http://abcdefghijklmnopqrxzy.herokuapp.com/parse', // Don't forget to change to https if needed
fileKey: process.env.PARSE_FILE_KEY || '&abcdefghijklmnopqrxzy',

<<<<<<< HEAD
serverURL: process.env.SERVER_URL || '&http://abcdefghijklmnopqrxzy.herokuapp.com/parse', // Don't forget to change to https if needed

=======

});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: 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://abcdefghijklmnopqrxzy.herokuapp.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'abcdefghijklmnopqrxzy',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: '&reset@abcdefghijklmnopqrxzy.com',
// Your domain from mailgun.com
domain: '&mg.abcdefghijklmnopqrxzy.com',
// Your API key from mailgun.com
apiKey: '&key-abcdefghijklmnopqrxzy',
}
},

});

var app = express();

// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

WHAT AM I DOING WRONG?! THIS IS DRIVING ME NUTS :(

@FeleciaGenet
Copy link

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?

@flovilmart
Copy link
Contributor

you should not have the specs in your parse-server installation. How did you install parse-server? Did you use parse-server-example?

@FeleciaGenet
Copy link

FeleciaGenet commented Jul 7, 2017

I did, back in January. I followed the migration guide.

@flovilmart
Copy link
Contributor

ok, to install the mail adapter, did you run npm install --save parse-server-simple-mailgun-adapter

@FeleciaGenet
Copy link

Yes in this way:

"
Felecias-iMac:~ feleciacoleman$ cd parse-server
Felecias-iMac:parse-server feleciacoleman$ npm i parse-server-simple-mailgun-adapter
parse-server@2.3.2 /Users/feleciacoleman/parse-server
└── parse-server-simple-mailgun-adapter@1.0.0

Felecias-iMac:parse-server feleciacoleman$

"

it is correct to install this directly in the parse-server directory, yes?

@FeleciaGenet
Copy link

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.

@flovilmart
Copy link
Contributor

how did you install it? did you clone the repository and deploy that? Did you follow the installation instructions?

@FeleciaGenet
Copy link

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.

@flovilmart
Copy link
Contributor

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...

@flovilmart
Copy link
Contributor

flovilmart commented Jul 7, 2017

$ brew search parse-server
No formula found for "parse-server".

Not even sure how you got there...

@FeleciaGenet
Copy link

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.

@crislucan
Copy link

#527

@flinn
Copy link

flinn commented Jul 14, 2017

@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_modules folder and the package.json file resides. From within that directory or any sub directory you can run the npm install PACKAGE_NAME --save command from a terminal window and it will install the package into the node_modules folder in a flat/de-nested way and update your package.json file to reflect the package being installed (assuming you have that --save flag)... Essentially you should never have to go into node_modules/parse-server and run any installation commands or change code/configurations there. Due to the way that NodeJS's global require('package-name') command works, the parse-server code will be able to find and utilize the parse-server-simple-mailgun-adapter code 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 your node_modules folder 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 the node_modules folder 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.

@adamofsky
Copy link

adamofsky commented Jul 17, 2017

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 false

publicServerURL: '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: 'a@a.com',
// 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 happen

What 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 a@gmail.comy.' } code=205, message=No user found with email a@gmail.comy.
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.

@amitkh6
Copy link

amitkh6 commented Jul 16, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests