0

Azure B2C login authentication is implemented. Sitecore virtual user is created as like below after b2c login success. Suddenly the

Sitecore.Context.User.Profile.GetCustomProperty("customEmail")

and

Sitecore.Context.User.Profile.Email 

returns empty value on the subsequent pages. From the past 3 months its return the email on the subsequent pages.

Any idea how to retain the value? or any temporary workaround? Note: Sitecore user profile only not persisted; still the logged in user is same on the subsequent pages(not anonymous user).

Sitecore.Security.Accounts.User user = Sitecore.Security.Authentication.AuthenticationManager.BuildVirtualUser(@"domain\user", true);
if (user != null)
{
   string domainRole = @"domain\role";
   if (Sitecore.Security.Accounts.Role.Exists(domainRole))
   {
     user.Roles.Add(Role.FromName(domainRole));
   }

   user.Profile.Email = "user@domain.com";
   user.Profile["customEmail"] = "user@domain.com";
   user.Profile.Save();
   Sitecore.Security.Authentication.AuthenticationManager.LoginVirtualUser(user);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.