@@ -1763,6 +1763,43 @@ describe('User', function() {
17631763 } ) ;
17641764 } ) ;
17651765
1766+ describe ( 'password reset with/without email verification' , function ( ) {
1767+ it ( 'allows resetPassword by email if email verification is required and done' ,
1768+ function ( done ) {
1769+ User . settings . emailVerificationRequired = true ;
1770+ var email = validCredentialsEmailVerified . email ;
1771+
1772+ User . resetPassword ( { email : email } , function ( err , info ) {
1773+ if ( err ) return done ( err ) ;
1774+ done ( ) ;
1775+ } ) ;
1776+ } ) ;
1777+
1778+ it ( 'disallows resetPassword by email if email verification is required and not done' ,
1779+ function ( done ) {
1780+ User . settings . emailVerificationRequired = true ;
1781+ var email = validCredentialsEmail ;
1782+
1783+ User . resetPassword ( { email : email } , function ( err ) {
1784+ assert ( err ) ;
1785+ assert . equal ( err . code , 'RESET_FAILED_EMAIL_NOT_VERIFIED' ) ;
1786+ assert . equal ( err . statusCode , 401 ) ;
1787+ done ( ) ;
1788+ } ) ;
1789+ } ) ;
1790+
1791+ it ( 'allows resetPassword by email if email verification is not required' ,
1792+ function ( done ) {
1793+ User . settings . emailVerificationRequired = false ;
1794+ var email = validCredentialsEmail ;
1795+
1796+ User . resetPassword ( { email : email } , function ( err ) {
1797+ if ( err ) return done ( err ) ;
1798+ done ( ) ;
1799+ } ) ;
1800+ } ) ;
1801+ } ) ;
1802+
17661803 describe ( 'ctor' , function ( ) {
17671804 it ( 'exports default Email model' , function ( ) {
17681805 expect ( User . email , 'User.email' ) . to . be . a ( 'function' ) ;
0 commit comments