File tree 2 files changed +34
-0
lines changed 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1524,6 +1524,36 @@ describe('Parse.User testing', () => {
1524
1524
done ( ) ;
1525
1525
} ) ;
1526
1526
1527
+ it ( 'login with provider should be blockable by beforeLogin even when the user has a attached file' , async done => {
1528
+ const provider = getMockFacebookProvider ( ) ;
1529
+ Parse . User . _registerAuthenticationProvider ( provider ) ;
1530
+
1531
+ let hit = 0 ;
1532
+ Parse . Cloud . beforeLogin ( req => {
1533
+ hit ++ ;
1534
+ if ( req . object . get ( 'isBanned' ) ) {
1535
+ throw new Error ( 'banned account' ) ;
1536
+ }
1537
+ } ) ;
1538
+
1539
+ const user = await Parse . User . _logInWith ( 'facebook' ) ;
1540
+ const base64 = 'aHR0cHM6Ly9naXRodWIuY29tL2t2bmt1YW5n' ;
1541
+ const file = new Parse . File ( 'myfile.txt' , { base64 } ) ;
1542
+ await file . save ( ) ;
1543
+ await user . save ( { isBanned : true , file } ) ;
1544
+ await Parse . User . logOut ( ) ;
1545
+
1546
+ try {
1547
+ await Parse . User . _logInWith ( 'facebook' ) ;
1548
+ throw new Error ( 'should not have continued login.' ) ;
1549
+ } catch ( e ) {
1550
+ expect ( e . message ) . toBe ( 'banned account' ) ;
1551
+ }
1552
+
1553
+ expect ( hit ) . toBe ( 1 ) ;
1554
+ done ( ) ;
1555
+ } ) ;
1556
+
1527
1557
it ( 'logout with provider should call afterLogout trigger' , async done => {
1528
1558
const provider = getMockFacebookProvider ( ) ;
1529
1559
Parse . User . _registerAuthenticationProvider ( provider ) ;
Original file line number Diff line number Diff line change @@ -329,6 +329,10 @@ RestWrite.prototype.runBeforeLoginTrigger = async function(userData) {
329
329
330
330
// Cloud code gets a bit of extra data for its objects
331
331
const extraData = { className : this . className } ;
332
+
333
+ // Expand file objects
334
+ this . config . filesController . expandFilesInObject ( this . config , userData ) ;
335
+
332
336
const user = triggers . inflate ( extraData , userData ) ;
333
337
334
338
// no need to return a response
You can’t perform that action at this time.
0 commit comments