File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1438,6 +1438,32 @@ describe('Parse.User testing', () => {
1438
1438
} ) ;
1439
1439
} ) ;
1440
1440
1441
+ it ( 'should fail linking with existing' , ( done ) => {
1442
+ var provider = getMockFacebookProvider ( ) ;
1443
+ Parse . User . _registerAuthenticationProvider ( provider ) ;
1444
+ Parse . User . _logInWith ( "facebook" , {
1445
+ success : function ( model ) {
1446
+ let userId = model . id ;
1447
+ Parse . User . logOut ( ) . then ( ( ) => {
1448
+ request . post ( {
1449
+ url :Parse . serverURL + '/classes/_User' ,
1450
+ headers : {
1451
+ 'X-Parse-Application-Id' : Parse . applicationId ,
1452
+ 'X-Parse-REST-API-Key' : 'rest'
1453
+ } ,
1454
+ json : { authData : { facebook : provider . authData } }
1455
+ } , ( err , res , body ) => {
1456
+ // make sure the location header is properly set
1457
+ expect ( userId ) . not . toBeUndefined ( ) ;
1458
+ expect ( body . objectId ) . toEqual ( userId ) ;
1459
+ expect ( res . headers . location ) . toEqual ( Parse . serverURL + '/users/' + userId ) ;
1460
+ done ( ) ;
1461
+ } ) ;
1462
+ } ) ;
1463
+ }
1464
+ } ) ;
1465
+ } ) ;
1466
+
1441
1467
it ( 'should have authData in beforeSave and afterSave' , ( done ) => {
1442
1468
1443
1469
Parse . Cloud . beforeSave ( '_User' , ( request , response ) => {
Original file line number Diff line number Diff line change @@ -285,11 +285,12 @@ RestWrite.prototype.handleAuthData = function(authData) {
285
285
// Login with auth data
286
286
// Short circuit
287
287
delete results [ 0 ] . password ;
288
+ // need to set the objectId first otherwise location has trailing undefined
289
+ this . data . objectId = results [ 0 ] . objectId ;
288
290
this . response = {
289
291
response : results [ 0 ] ,
290
292
location : this . location ( )
291
293
} ;
292
- this . data . objectId = results [ 0 ] . objectId ;
293
294
} else if ( this . query && this . query . objectId ) {
294
295
// Trying to update auth data but users
295
296
// are different
You can’t perform that action at this time.
0 commit comments