Document email adapter

This commit is contained in:
Drew Gross
2016-03-22 22:09:22 -07:00
parent f4ad4c1af5
commit 2f00a02936
5 changed files with 75 additions and 46 deletions

View File

@@ -187,6 +187,36 @@ The client keys used with Parse are no longer necessary with Parse Server. If yo
* `loggerAdapter` - The default behavior/transport (File) can be changed by creating an adapter class (see [`LoggerAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Logger/LoggerAdapter.js)). * `loggerAdapter` - The default behavior/transport (File) can be changed by creating an adapter class (see [`LoggerAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Logger/LoggerAdapter.js)).
* `databaseAdapter` - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`). Defaults to `MongoStorageAdapter`. * `databaseAdapter` - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`). Defaults to `MongoStorageAdapter`.
##### Email verification and password reset
Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the `parse-server` package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
```js
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
publicServerURL: 'https://example.com',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server/lib/Adapters/Email/SimpleMailgunAdapter',
options: {
// The addres that your emails come from
fromAddress: 'parse@example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
You can also use other email adapters contributed by the community such as [parse-server-sendgrid-adapter](https://www.npmjs.com/package/parse-server-sendgrid-adapter).
### Using environment variables to configure Parse Server ### Using environment variables to configure Parse Server
You may configure the Parse Server using environment variables: You may configure the Parse Server using environment variables:

View File

@@ -1,8 +1,8 @@
import Mailgun from 'mailgun-js'; import Mailgun from 'mailgun-js';
let SimpleMailgunAdapter = mailgunOptions => { let SimpleMailgunAdapter = mailgunOptions => {
if (!mailgunOptions || !mailgunOptions.apiKey || !mailgunOptions.domain) { if (!mailgunOptions || !mailgunOptions.apiKey || !mailgunOptions.domain || !mailgunOptions.fromAddress) {
throw 'SimpleMailgunAdapter requires an API Key and domain.'; throw 'SimpleMailgunAdapter requires an API Key, domain, and fromAddress.';
} }
let mailgun = Mailgun(mailgunOptions); let mailgun = Mailgun(mailgunOptions);

View File

@@ -181,7 +181,7 @@ export class UserController extends AdaptableController {
defaultVerificationEmail({link, user, appName, }) { defaultVerificationEmail({link, user, appName, }) {
let text = "Hi,\n\n" + let text = "Hi,\n\n" +
"You are being asked to confirm the e-mail address " + user.email + " with " + appName + "\n\n" + "You are being asked to confirm the e-mail address " + user.get("email") + " with " + appName + "\n\n" +
"" + "" +
"Click here to confirm it:\n" + link; "Click here to confirm it:\n" + link;
let to = user.get("email"); let to = user.get("email");

View File

@@ -11,7 +11,6 @@ var batch = require('./batch'),
Parse = require('parse/node').Parse, Parse = require('parse/node').Parse,
authDataManager = require('./authDataManager'); authDataManager = require('./authDataManager');
//import passwordReset from './passwordReset';
import cache from './cache'; import cache from './cache';
import Config from './Config'; import Config from './Config';
import parseServerPackage from '../package.json'; import parseServerPackage from '../package.json';

View File

@@ -1,7 +1,7 @@
import ParseServer from './ParseServer' import ParseServer from './ParseServer'
import { GCSAdapter } from 'parse-server-gcs-adapter'; import { FileSystemAdapter } from './Adapters/Files/FileSystemAdapter';
import { S3Adapter } from 'parse-server-s3-adapter'; import { GCSAdapter } from './Adapters/Files/GCSAdapter';
import { FileSystemAdapter } from 'parse-server-fs-adapter'; import { S3Adapter } from './Adapters/Files/S3Adapter';
// Factory function // Factory function
let _ParseServer = function(options) { let _ParseServer = function(options) {