Skip to content

Commit fe1bee1

Browse files
author
James
authored
Update docs to mirror the server readme
Saw it mentioned in parse-community/parse-server#275 a few times, and took me a while to find it, so updating here too. Not sure what the longer term plans are regarding docs, seems to be multiple places for the same docs
1 parent e5ec6ae commit fe1bee1

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

_includes/parse-server/compatibility.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,78 @@ Facebook, Twitter, and Anonymous logins are supported out of the box. Support fo
181181

182182
## Welcome Emails and Email Verification
183183

184-
This is not supported out of the box. But, you can use a `beforeSave` to send out emails using a provider like Mailgun and add logic for verification. [Subscribe to this issue](https://github.com/parse-community/parse-server/issues/275) to be notified if email verification support is added to Parse Server.
184+
Verifying user email addresses and enabling password reset via email requires 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:
185+
186+
```js
187+
var server = ParseServer({
188+
...otherOptions,
189+
// Enable email verification
190+
verifyUserEmails: true,
191+
192+
// if `verifyUserEmails` is `true` and
193+
// if `emailVerifyTokenValidityDuration` is `undefined` then
194+
// email verify token never expires
195+
// else
196+
// email verify token expires after `emailVerifyTokenValidityDuration`
197+
//
198+
// `emailVerifyTokenValidityDuration` defaults to `undefined`
199+
//
200+
// email verify token below expires in 2 hours (= 2 * 60 * 60 == 7200 seconds)
201+
emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
202+
203+
// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email
204+
// set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified
205+
preventLoginWithUnverifiedEmail: false, // defaults to false
206+
207+
// The public URL of your app.
208+
// This will appear in the link that is used to verify email addresses and reset passwords.
209+
// Set the mount path as it is in serverURL
210+
publicServerURL: 'https://example.com/parse',
211+
// Your apps name. This will appear in the subject and body of the emails that are sent.
212+
appName: 'Parse App',
213+
// The email adapter
214+
emailAdapter: {
215+
module: '@parse/simple-mailgun-adapter',
216+
options: {
217+
// The address that your emails come from
218+
fromAddress: '[email protected]',
219+
// Your domain from mailgun.com
220+
domain: 'example.com',
221+
// Your API key from mailgun.com
222+
apiKey: 'key-mykey',
223+
}
224+
},
225+
226+
// account lockout policy setting (OPTIONAL) - defaults to undefined
227+
// if the account lockout policy is set and there are more than `threshold` number of failed login attempts then the `login` api call returns error code `Parse.Error.OBJECT_NOT_FOUND` with error message `Your account is locked due to multiple failed login attempts. Please try again after <duration> minute(s)`. After `duration` minutes of no login attempts, the application will allow the user to try login again.
228+
accountLockout: {
229+
duration: 5, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000.
230+
threshold: 3, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000.
231+
},
232+
// optional settings to enforce password policies
233+
passwordPolicy: {
234+
// Two optional settings to enforce strong passwords. Either one or both can be specified.
235+
// If both are specified, both checks must pass to accept the password
236+
// 1. a RegExp object or a regex string representing the pattern to enforce
237+
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/, // enforce password with at least 8 char with at least 1 lower case, 1 upper case and 1 digit
238+
// 2. a callback function to be invoked to validate the password
239+
validatorCallback: (password) => { return validatePassword(password) },
240+
doNotAllowUsername: true, // optional setting to disallow username in passwords
241+
maxPasswordAge: 90, // optional setting in days for password expiry. Login fails if user does not reset the password within this period after signup/last reset.
242+
maxPasswordHistory: 5, // optional setting to prevent reuse of previous n passwords. Maximum value that can be specified is 20. Not specifying it or specifying 0 will not enforce history.
243+
//optional setting to set a validity duration for password reset links (in seconds)
244+
resetTokenValidityDuration: 24*60*60, // expire after 24 hours
245+
}
246+
});
247+
```
248+
249+
You can also use other email adapters contributed by the community such as:
250+
- [parse-server-postmark-adapter](https://www.npmjs.com/package/parse-server-postmark-adapter)
251+
- [parse-server-sendgrid-adapter](https://www.npmjs.com/package/parse-server-sendgrid-adapter)
252+
- [parse-server-mandrill-adapter](https://www.npmjs.com/package/parse-server-mandrill-adapter)
253+
- [parse-server-simple-ses-adapter](https://www.npmjs.com/package/parse-server-simple-ses-adapter)
254+
- [parse-server-mailgun-adapter-template](https://www.npmjs.com/package/parse-server-mailgun-adapter-template)
255+
- [parse-server-sendinblue-adapter](https://www.npmjs.com/package/parse-server-sendinblue-adapter)
256+
- [parse-server-mailjet-adapter](https://www.npmjs.com/package/parse-server-mailjet-adapter)
257+
- [simple-parse-smtp-adapter](https://www.npmjs.com/package/simple-parse-smtp-adapter)
258+
- [parse-server-generic-email-adapter](https://www.npmjs.com/package/parse-server-generic-email-adapter)

0 commit comments

Comments
 (0)