Skip to content

Commit f2e21b0

Browse files
paulovitinmontymxb
authored andcommitted
Additional test for emailVerified set to false on email changed from existing (#4532)
* Create a test to check the issue #4501 * Check if after the user confirms the email and change the email again a new verification email is sent * Change the spec text to requested in PR
1 parent 550b69e commit f2e21b0

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

spec/EmailVerificationToken.spec.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,4 +777,63 @@ describe("Email Verification Token Expiration: ", () => {
777777
});
778778
});
779779

780+
it('emailVerified should be set to false after changing from an already verified email', done => {
781+
var user = new Parse.User();
782+
var sendEmailOptions;
783+
var emailAdapter = {
784+
sendVerificationEmail: options => {
785+
sendEmailOptions = options;
786+
},
787+
sendPasswordResetEmail: () => Promise.resolve(),
788+
sendMail: () => { }
789+
}
790+
reconfigureServer({
791+
appName: 'emailVerifyToken',
792+
verifyUserEmails: true,
793+
emailAdapter: emailAdapter,
794+
emailVerifyTokenValidityDuration: 5, // 5 seconds
795+
publicServerURL: "http://localhost:8378/1"
796+
})
797+
.then(() => {
798+
user.setUsername("testEmailVerifyTokenValidity");
799+
user.setPassword("expiringToken");
800+
user.set('email', '[email protected]');
801+
return user.signUp();
802+
}).then(() => {
803+
request.get(sendEmailOptions.link, {
804+
followRedirect: false,
805+
}, (error, response) => {
806+
expect(response.statusCode).toEqual(302);
807+
Parse.User.logIn("testEmailVerifyTokenValidity", "expiringToken")
808+
.then(user => {
809+
expect(typeof user).toBe('object');
810+
expect(user.get('emailVerified')).toBe(true);
811+
812+
user.set('email', '[email protected]');
813+
return user.save();
814+
})
815+
.then(() => user.fetch())
816+
.then(user => {
817+
expect(typeof user).toBe('object');
818+
expect(user.get('email')).toBe('[email protected]');
819+
expect(user.get('emailVerified')).toBe(false);
820+
821+
request.get(sendEmailOptions.link, {
822+
followRedirect: false,
823+
}, (error, response) => {
824+
expect(response.statusCode).toEqual(302);
825+
done();
826+
});
827+
})
828+
.catch((error) => {
829+
jfail(error);
830+
done();
831+
});
832+
});
833+
}).catch((error) => {
834+
jfail(error);
835+
done();
836+
});
837+
});
838+
780839
})

0 commit comments

Comments
 (0)