File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 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 {
469469 if (options.hasOwnProperty('usePost')) {
470470 loginOptions . usePost = options . usePost ;
471471 }
472-
472+ if (
473+ options.hasOwnProperty('context') &&
474+ Object . prototype . toString . call ( options . context ) === '[ object Object ] '
475+ ) {
476+ loginOptions . context = options . context ;
477+ }
473478 const controller = CoreManager.getUserController();
474479 return controller.logIn(this, loginOptions);
475480 }
Original file line number Diff line number Diff line change @@ -1942,6 +1942,27 @@ describe('ParseUser', () => {
19421942 expect ( controller . request . mock . calls [ 0 ] [ 3 ] . context ) . toEqual ( context ) ;
19431943 } ) ;
19441944
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+
19451966 it ( 'can verify user password' , async ( ) => {
19461967 ParseUser . enableUnsafeCurrentUser ( ) ;
19471968 ParseUser . _clearCache ( ) ;
You can’t perform that action at this time.
0 commit comments