We have a lightning community, as well as a VF community that holds a cloudcraze/B2B commerce storefront. Within the lightning community we are calling cloudcraze APIs for things like user registration.
Currently, we are successfully registering users (by calling the cloudcraze user registration API). Immediately after registering a user successfully, we call the Site.login() method to log the user into the community. Both registration and login are successful - we have confirmed this through debug logs and by checking the login history of the org to see that those users have logged into the proper community.
Unfortunately, we are facing a weird problem where the current user doesn't seem to change. Using debug logs, we see that the current user is the same both before registration + login and after (it's the community guest user).
If we log in through Salesforce by going to a contact and clicking "Log into community as user", Salesforce correctly recognizes the current user.