Skip to content

Commit 12d4b15

Browse files
committed
Stop requiring verifyUserEmails for password reset functionality
1 parent a73f150 commit 12d4b15

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

spec/ValidationAndPasswordsReset.spec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ describe("Custom Pages, Email Verification, Password Reset", () => {
238238
});
239239
});
240240

241-
it_exclude_dbs(['postgres'])('fails if you include an emailAdapter, set verifyUserEmails to false, dont set a publicServerURL, and try to send a password reset email (regression test for #1649)', done => {
241+
it_exclude_dbs(['postgres'])('fails if you include an emailAdapter, set a publicServerURL, but have no appName and send a password reset email', done => {
242242
reconfigureServer({
243-
appName: 'unused',
244-
verifyUserEmails: false,
243+
appName: undefined,
244+
publicServerURL: 'http://localhost:1337/1',
245245
emailAdapter: MockEmailAdapterWithOptions({
246246
fromAddress: 'parse@example.com',
247247
apiKey: 'k',
@@ -278,6 +278,7 @@ describe("Custom Pages, Email Verification, Password Reset", () => {
278278
}
279279
reconfigureServer({
280280
appName: 'unused',
281+
publicServerURL: 'http://localhost:1337/1',
281282
verifyUserEmails: false,
282283
emailAdapter: emailAdapter,
283284
})

src/Config.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ export class Config {
5656

5757
static validate({
5858
verifyUserEmails,
59+
userController,
5960
appName,
6061
publicServerURL,
6162
revokeSessionOnPasswordReset,
6263
expireInactiveSessions,
6364
sessionLength,
6465
}) {
65-
this.validateEmailConfiguration({
66-
verifyUserEmails: verifyUserEmails,
67-
appName: appName,
68-
publicServerURL: publicServerURL
69-
})
66+
const emailAdapter = userController.adapter;
67+
if (verifyUserEmails) {
68+
this.validateEmailConfiguration({emailAdapter, appName, publicServerURL});
69+
}
7070

7171
if (typeof revokeSessionOnPasswordReset !== 'boolean') {
7272
throw 'revokeSessionOnPasswordReset must be a boolean value';
@@ -81,13 +81,13 @@ export class Config {
8181
this.validateSessionConfiguration(sessionLength, expireInactiveSessions);
8282
}
8383

84-
static validateEmailConfiguration({verifyUserEmails, appName, publicServerURL}) {
85-
if (verifyUserEmails) {
84+
static validateEmailConfiguration({emailAdapter, appName, publicServerURL}) {
85+
if (emailAdapter) {
8686
if (typeof appName !== 'string') {
87-
throw 'An app name is required when using email verification.';
87+
throw 'An app name is required for e-mail verification and password resets.';
8888
}
8989
if (typeof publicServerURL !== 'string') {
90-
throw 'A public server url is required when using email verification.';
90+
throw 'A public server url is required for e-mail verification and password resets.';
9191
}
9292
}
9393
}

src/Routers/UsersRouter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class UsersRouter extends ClassesRouter {
158158
handleResetRequest(req) {
159159
try {
160160
Config.validateEmailConfiguration({
161-
verifyUserEmails: true, //A bit of a hack, as this isn't the intended purpose of this parameter
161+
emailAdapter: req.config.userController,
162162
appName: req.config.appName,
163163
publicServerURL: req.config.publicServerURL,
164164
});

0 commit comments

Comments
 (0)