Skip to content

Commit 34b51f7

Browse files
committed
Add failing test to show
that changing a user's email does not delete their perishable token.
1 parent 317682d commit 34b51f7

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

spec/ValidationAndPasswordsReset.spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,4 +909,56 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
909909
});
910910
});
911911
});
912+
913+
it('deletes password reset token', done => {
914+
reconfigureServer({
915+
appName: 'coolapp',
916+
publicServerURL: 'http://localhost:1337/1',
917+
emailAdapter: MockEmailAdapterWithOptions({
918+
fromAddress: '[email protected]',
919+
apiKey: 'k',
920+
domain: 'd',
921+
}),
922+
})
923+
.then(() => {
924+
const config = Config.get('test');
925+
const user = new Parse.User();
926+
user.setPassword('asdf');
927+
user.setUsername('zxcv');
928+
user.set('email', '[email protected]');
929+
return user
930+
.signUp(null)
931+
.then(() => Parse.User.requestPasswordReset('[email protected]'))
932+
.then(() => config.database.adapter
933+
.find(
934+
'_User',
935+
{ fields: {} },
936+
{ username: 'zxcv' },
937+
{ limit: 1 }
938+
))
939+
.then(results => {
940+
// validate that there is a token
941+
expect(results.length).toEqual(1);
942+
expect(results[0]['_perishable_token']).not.toBeNull();
943+
user.set('email', '[email protected]');
944+
return user.save();
945+
})
946+
.then(() => config.database.adapter
947+
.find(
948+
'_User',
949+
{ fields: {} },
950+
{ username: 'zxcv' },
951+
{ limit: 1 })
952+
)
953+
.then(results => {
954+
expect(results.length).toEqual(1);
955+
expect(results[0]['_perishable_token']).toBeNull();
956+
done();
957+
})
958+
})
959+
.catch(error => {
960+
fail(JSON.stringify(error));
961+
done();
962+
});
963+
});
912964
});

0 commit comments

Comments
 (0)