File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,12 @@ class ParseUser extends ParseObject {
469
469
if (options.hasOwnProperty('usePost')) {
470
470
loginOptions . usePost = options . usePost ;
471
471
}
472
-
472
+ if (
473
+ options.hasOwnProperty('context') &&
474
+ Object . prototype . toString . call ( options . context ) === '[ object Object ] '
475
+ ) {
476
+ loginOptions . context = options . context ;
477
+ }
473
478
const controller = CoreManager.getUserController();
474
479
return controller.logIn(this, loginOptions);
475
480
}
Original file line number Diff line number Diff line change @@ -1942,6 +1942,27 @@ describe('ParseUser', () => {
1942
1942
expect ( controller . request . mock . calls [ 0 ] [ 3 ] . context ) . toEqual ( context ) ;
1943
1943
} ) ;
1944
1944
1945
+ it ( 'can login with context' , async ( ) => {
1946
+ CoreManager . setRESTController ( {
1947
+ ajax ( ) { } ,
1948
+ request ( ) {
1949
+ return Promise . resolve (
1950
+ {
1951
+ objectId : 'uid33' ,
1952
+ username : 'username' ,
1953
+ sessionToken : '123abc' ,
1954
+ } ,
1955
+ 200
1956
+ ) ;
1957
+ } ,
1958
+ } ) ;
1959
+ const controller = CoreManager . getRESTController ( ) ;
1960
+ jest . spyOn ( controller , 'request' ) ;
1961
+ const context = { a : 'a' } ;
1962
+ await ParseUser . logIn ( 'username' , 'password' , { context } ) ;
1963
+ expect ( controller . request . mock . calls [ 0 ] [ 3 ] . context ) . toEqual ( context ) ;
1964
+ } ) ;
1965
+
1945
1966
it ( 'can verify user password' , async ( ) => {
1946
1967
ParseUser . enableUnsafeCurrentUser ( ) ;
1947
1968
ParseUser . _clearCache ( ) ;
You can’t perform that action at this time.
0 commit comments