Stop requiring verifyUserEmails for password reset functionality (#2166)
This commit is contained in:
committed by
Florent Vilmart
parent
a73f150a1a
commit
799e59618c
@@ -238,10 +238,10 @@ describe("Custom Pages, Email Verification, Password Reset", () => {
|
||||
});
|
||||
});
|
||||
|
||||
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 => {
|
||||
it_exclude_dbs(['postgres'])('fails if you include an emailAdapter, set a publicServerURL, but have no appName and send a password reset email', done => {
|
||||
reconfigureServer({
|
||||
appName: 'unused',
|
||||
verifyUserEmails: false,
|
||||
appName: undefined,
|
||||
publicServerURL: 'http://localhost:1337/1',
|
||||
emailAdapter: MockEmailAdapterWithOptions({
|
||||
fromAddress: 'parse@example.com',
|
||||
apiKey: 'k',
|
||||
@@ -278,6 +278,7 @@ describe("Custom Pages, Email Verification, Password Reset", () => {
|
||||
}
|
||||
reconfigureServer({
|
||||
appName: 'unused',
|
||||
publicServerURL: 'http://localhost:1337/1',
|
||||
verifyUserEmails: false,
|
||||
emailAdapter: emailAdapter,
|
||||
})
|
||||
|
||||
@@ -56,17 +56,17 @@ export class Config {
|
||||
|
||||
static validate({
|
||||
verifyUserEmails,
|
||||
userController,
|
||||
appName,
|
||||
publicServerURL,
|
||||
revokeSessionOnPasswordReset,
|
||||
expireInactiveSessions,
|
||||
sessionLength,
|
||||
}) {
|
||||
this.validateEmailConfiguration({
|
||||
verifyUserEmails: verifyUserEmails,
|
||||
appName: appName,
|
||||
publicServerURL: publicServerURL
|
||||
})
|
||||
const emailAdapter = userController.adapter;
|
||||
if (verifyUserEmails) {
|
||||
this.validateEmailConfiguration({emailAdapter, appName, publicServerURL});
|
||||
}
|
||||
|
||||
if (typeof revokeSessionOnPasswordReset !== 'boolean') {
|
||||
throw 'revokeSessionOnPasswordReset must be a boolean value';
|
||||
@@ -81,13 +81,13 @@ export class Config {
|
||||
this.validateSessionConfiguration(sessionLength, expireInactiveSessions);
|
||||
}
|
||||
|
||||
static validateEmailConfiguration({verifyUserEmails, appName, publicServerURL}) {
|
||||
if (verifyUserEmails) {
|
||||
static validateEmailConfiguration({emailAdapter, appName, publicServerURL}) {
|
||||
if (emailAdapter) {
|
||||
if (typeof appName !== 'string') {
|
||||
throw 'An app name is required when using email verification.';
|
||||
throw 'An app name is required for e-mail verification and password resets.';
|
||||
}
|
||||
if (typeof publicServerURL !== 'string') {
|
||||
throw 'A public server url is required when using email verification.';
|
||||
throw 'A public server url is required for e-mail verification and password resets.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export class UsersRouter extends ClassesRouter {
|
||||
handleResetRequest(req) {
|
||||
try {
|
||||
Config.validateEmailConfiguration({
|
||||
verifyUserEmails: true, //A bit of a hack, as this isn't the intended purpose of this parameter
|
||||
emailAdapter: req.config.userController,
|
||||
appName: req.config.appName,
|
||||
publicServerURL: req.config.publicServerURL,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user