File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -539,6 +539,21 @@ export default class ParseUser extends ParseObject {
539
539
* the login completes.
540
540
*/
541
541
static logIn ( username , password , options ) {
542
+ if ( typeof username !== 'string' ) {
543
+ return ParsePromise . error (
544
+ new ParseError (
545
+ ParseError . OTHER_CAUSE ,
546
+ 'Username must be a string.'
547
+ )
548
+ ) ;
549
+ } else if ( typeof password !== 'string' ) {
550
+ return ParsePromise . error (
551
+ new ParseError (
552
+ ParseError . OTHER_CAUSE ,
553
+ 'Password must be a string.'
554
+ )
555
+ ) ;
556
+ }
542
557
var user = new ParseUser ( ) ;
543
558
user . _finishFetch ( { username : username , password : password } ) ;
544
559
return user . logIn ( options ) ;
Original file line number Diff line number Diff line change @@ -179,6 +179,22 @@ describe('ParseUser', () => {
179
179
} ) ;
180
180
} ) ) ;
181
181
182
+ it ( 'fail login when invalid username or password is used' , asyncHelper ( ( done ) => {
183
+ ParseUser . enableUnsafeCurrentUser ( ) ;
184
+ ParseUser . _clearCache ( ) ;
185
+ ParseUser . logIn ( { } , 'password' ) . then ( null , ( err ) => {
186
+ expect ( err . code ) . toBe ( ParseError . OTHER_CAUSE ) ;
187
+ expect ( err . message ) . toBe ( 'Username must be a string.' ) ;
188
+
189
+ return ParseUser . logIn ( 'username' , { } ) ;
190
+ } ) . then ( null , ( err ) => {
191
+ expect ( err . code ) . toBe ( ParseError . OTHER_CAUSE ) ;
192
+ expect ( err . message ) . toBe ( 'Password must be a string.' ) ;
193
+
194
+ done ( ) ;
195
+ } ) ;
196
+ } ) ) ;
197
+
182
198
it ( 'preserves changes when logging in' , asyncHelper ( ( done ) => {
183
199
ParseUser . enableUnsafeCurrentUser ( ) ;
184
200
ParseUser . _clearCache ( ) ;
You can’t perform that action at this time.
0 commit comments