getCurrentUser returns last added user

I am using backendless 4 in a js app for administering company staff. I am seeing what I think is unexpected behaviour, here is short summary:-
Admin of the app logs in: lets say that is me, Mike
Backendless.UserService.login(username, password, remember).then(userLoggedIn, gotError);
As expected the Backendless.UserService.getCurrentUser() will be ‘Mike’
If ‘Mike’ then adds a new user via the app with soemthing like
var newuser = new Backendless.User();
newuser.name = “Fred”;
newuser.email = "Fred@xyz.com"
newuser.password = “password”;
Backendless.UserService.register( user ).then( userRegistered ).catch( gotError );
If I now call Backendless.UserService.getCurrentUser() then this returns the newly added user ‘Fred’.
I had expected that getCurrentUser() would still be the logged in user ‘Mike’ ? Fred is simply added as a new user and not logged in.
Is this expected behaviour or am I misreading the docs or doing something wrong? If I shouldn’t call getCurrentUser() to retrieve the current logged in user ‘Mike’, what backendless call should I make instead?
Many thanks,
Mike

Hi Mike

Yes, it’s a bug, we will fix it asap and let you know here when the fix is released.

Regards, Vlad

the fix is released in version 4.4.2, please upgrade JS-SDK and let us know if the problem is solved for you.

Thanks,

Hi Vlad

Nice, one that has fixed it.

Thanks for your excellent support as normal.

Mike

Hi Vlad

I think I have a very similar issue related to the above (hence keeping it on some topic)

Like above, when creating a new user via Backendless.UserService.register( user ) would result in Backendless.UserService.getCurrentUser() returning the newly created user rather than the existing logged in user I think the same thing is happening with Backendless.UserService.update( user )

To expand…
Admin of the app (mike) logs into the app and wishes to change one of the users (lets say Fred)
I call this code,

var updatedUser = new Backendless.User();
updatedUser.objectId = data.objectId; //the objectId of the user we want to update (Fred)
updatedUser.lastname = newlastname; //new properties of Fred
Backendless.UserService.update( updatedUser )
.then( function( updatedUser ) {
}

That all works fine and expected, but after the update if I call Backendless.UserService.getCurrentUser() I get Fred and not Mike

Hi Mike

Good catch!
And the problem is also fixed and released in version 4.4.3
please check this out

Regards, Vlad

Fab, that works perfectly now :-). Thanks for the quick fix.

Regards, Mike