File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1438,6 +1438,32 @@ describe('Parse.User testing', () => {
14381438 } ) ;
14391439 } ) ;
14401440
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+
14411467 it ( 'should have authData in beforeSave and afterSave' , ( done ) => {
14421468
14431469 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) {
285285 // Login with auth data
286286 // Short circuit
287287 delete results [ 0 ] . password ;
288+ // need to set the objectId first otherwise location has trailing undefined
289+ this . data . objectId = results [ 0 ] . objectId ;
288290 this . response = {
289291 response : results [ 0 ] ,
290292 location : this . location ( )
291293 } ;
292- this . data . objectId = results [ 0 ] . objectId ;
293294 } else if ( this . query && this . query . objectId ) {
294295 // Trying to update auth data but users
295296 // are different
You can’t perform that action at this time.
0 commit comments