@@ -381,10 +381,6 @@ export default class ParseUser extends ParseObject {
381381 * the login is complete.
382382 */
383383 logIn ( options : FullOptions ) {
384- if ( ! canUseCurrentUser ) {
385- throw new Error ( 'It is not possible to log in on a server environment.' ) ;
386- }
387-
388384 options = options || { } ;
389385
390386 var loginOptions = { } ;
@@ -393,7 +389,7 @@ export default class ParseUser extends ParseObject {
393389 }
394390
395391 var controller = CoreManager . getUserController ( ) ;
396- return controller . logIn ( this , loginOptions ) . _thenRunCallbacks ( options ) ;
392+ return controller . logIn ( this , loginOptions ) . _thenRunCallbacks ( options , this ) ;
397393 }
398394
399395 static readOnlyAttributes ( ) {
@@ -639,7 +635,7 @@ export default class ParseUser extends ParseObject {
639635 }
640636
641637 /**
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
643639 * environment. These features are disabled by default, since they depend on
644640 * global objects that are not memory-safe for most servers.
645641 * @method enableUnsafeCurrentUser
@@ -649,6 +645,17 @@ export default class ParseUser extends ParseObject {
649645 canUseCurrentUser = true ;
650646 }
651647
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+
652659 static _registerAuthenticationProvider ( provider ) {
653660 authProviders [ provider . getAuthType ( ) ] = provider ;
654661 // Synchronize the current user with the auth provider.
@@ -818,6 +825,10 @@ var DefaultController = {
818825 ) ;
819826 response . password = undefined ;
820827 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+ }
821832 return DefaultController . setCurrentUser ( user ) ;
822833 } ) ;
823834 } ,
0 commit comments