parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Tips for implementing password reset?

Open tamarabernad opened this issue 10 years ago • 31 comments

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

tamarabernad avatar Jan 31 '16 11:01 tamarabernad

+1

yamill avatar Jan 31 '16 16:01 yamill

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 avatar Feb 01 '16 05:02 gfosco

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?

barcodehawk avatar Feb 01 '16 07:02 barcodehawk

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

gfosco avatar Feb 01 '16 07:02 gfosco

@gfosco Sounds, good thanks for your hint

tamarabernad avatar Feb 01 '16 08:02 tamarabernad

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

natario1 avatar Feb 01 '16 10:02 natario1

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

corbanb avatar Feb 16 '16 18:02 corbanb

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 avatar Feb 16 '16 19:02 gfosco

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.

seryoni avatar Mar 27 '16 16:03 seryoni

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

flovilmart avatar Mar 27 '16 16:03 flovilmart

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.

klemenzagar91 avatar Jul 03 '16 18:07 klemenzagar91

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

otmezger avatar Aug 17 '16 16:08 otmezger

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

flovilmart avatar Feb 15 '17 00:02 flovilmart

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!

valdezm avatar Feb 15 '17 19:02 valdezm

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.

w3care25 avatar Feb 24 '17 12:02 w3care25

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://[email protected]: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: '&[email protected]', // 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 avatar Jul 07 '17 04:07 FeleciaGenet

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?

FeleciaGenet avatar Jul 07 '17 16:07 FeleciaGenet

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

flovilmart avatar Jul 07 '17 16:07 flovilmart

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

FeleciaGenet avatar Jul 07 '17 16:07 FeleciaGenet

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

flovilmart avatar Jul 07 '17 16:07 flovilmart