SetCurrentUser() Function not implemented in JS-SDK

Hi guys,

I found that the setCurrentUser() function is not implemented in the JS-SDK. I’m trying to let my user stay logged in. I’m using Facebook simple login with following code:

const userId = Backendless.UserService.loggedInUser();
        if (userId) {
            //user exists, fetch data from backend
            Backendless.Persistence.of(Backendless.User).findById(userId, new Backendless.Async(
                (user) => {
                    //user object correctly returned
                    Backendless.UserService.setCurrentUser(user); //not implemented!
                },
                (error) => {
                    debugger;
                }
            ));
        }

any workarounds or fixes?
thanks
Martin

Hi, Martin!

Thank you for reporting!
CurrentUser object is read-only, it cannot be set manually.
We have a feature that allows you to pass boolean “stayLoggedIn” parameter into “login” method. Now we’re working on implementing this feature for social logins and it would be available soon.
best regards,
Alex

Thanks for the really fast response!

Is the “stayLoggedIn” parameter also available for “loginWithFacebook”? Didn’t find anything in the source code…

Unfortunately, not.

We are working on it right now. Internal task tag is 12250.
We shall notify you as soon as it would be available on production.
best regards,
Alex

okay, would be great. Waiting for it.

thanks!

Hi, Martin!

The updated lib is available on github.
Here is the method signature:

Backendless.UserService.loginWithFacebook(facebookFieldsMapping, permissions, callback, container, stayLoggedIn);
You can download it and try.
best regards,
Alex

Wow, this is amazing! Works like a charm. Thanks, Alexandr!

Would be great if you could update the type declarations, too. Just that VS Code doesn’t have to scream at me :wink:

Will be added soon too.

Thanks.

Stanislav