@@ -381,10 +381,6 @@ export default class ParseUser extends ParseObject {
381
381
* the login is complete.
382
382
*/
383
383
logIn ( options : FullOptions ) {
384
- if ( ! canUseCurrentUser ) {
385
- throw new Error ( 'It is not possible to log in on a server environment.' ) ;
386
- }
387
-
388
384
options = options || { } ;
389
385
390
386
var loginOptions = { } ;
@@ -393,7 +389,7 @@ export default class ParseUser extends ParseObject {
393
389
}
394
390
395
391
var controller = CoreManager . getUserController ( ) ;
396
- return controller . logIn ( this , loginOptions ) . _thenRunCallbacks ( options ) ;
392
+ return controller . logIn ( this , loginOptions ) . _thenRunCallbacks ( options , this ) ;
397
393
}
398
394
399
395
static readOnlyAttributes ( ) {
@@ -639,7 +635,7 @@ export default class ParseUser extends ParseObject {
639
635
}
640
636
641
637
/**
642
- * Enables the use of logIn, become, and a current user in a server
638
+ * Enables the use of become or the current user in a server
643
639
* environment. These features are disabled by default, since they depend on
644
640
* global objects that are not memory-safe for most servers.
645
641
* @method enableUnsafeCurrentUser
@@ -649,6 +645,17 @@ export default class ParseUser extends ParseObject {
649
645
canUseCurrentUser = true ;
650
646
}
651
647
648
+ /**
649
+ * Disables the use of become or the current user in any environment.
650
+ * These features are disabled on servers by default, since they depend on
651
+ * global objects that are not memory-safe for most servers.
652
+ * @method disableUnsafeCurrentUser
653
+ * @static
654
+ */
655
+ static disableUnsafeCurrentUser ( ) {
656
+ canUseCurrentUser = false ;
657
+ }
658
+
652
659
static _registerAuthenticationProvider ( provider ) {
653
660
authProviders [ provider . getAuthType ( ) ] = provider ;
654
661
// Synchronize the current user with the auth provider.
@@ -818,6 +825,10 @@ var DefaultController = {
818
825
) ;
819
826
response . password = undefined ;
820
827
user . _finishFetch ( response ) ;
828
+ if ( ! canUseCurrentUser ) {
829
+ // We can't set the current user, so just return the one we logged in
830
+ return ParsePromise . as ( user ) ;
831
+ }
821
832
return DefaultController . setCurrentUser ( user ) ;
822
833
} ) ;
823
834
} ,
0 commit comments