public async Task <IdentityResult> RegisterUser(RegisterModel userRegister) { KenticoUserManager <DubaiCultureUser> t = new KenticoUserManager <DubaiCultureUser>(new KenticoUserStore <DubaiCultureUser>(AppConfig.SiteName)); DubaiCultureUser user = new DubaiCultureUser { UserName = userRegister.UserName, FirstName = userRegister.FirstName, LastName = userRegister.LastName, Email = userRegister.UserName, Enabled = true }; IdentityResult result = await _userManager.CreateAsync(user, userRegister.Password); return(result); }
/// <summary> /// Creates users in Xperience based on external login data. /// </summary> private async Task <IdentityResult> CreateExternalUser(ExternalLoginInfo loginInfo) { // Prepares a new user entity based on the external login data Kentico.Membership.User user = new User { UserName = ValidationHelper.GetSafeUserName(loginInfo.DefaultUserName ?? loginInfo.Email, SiteContext.CurrentSiteName), Email = loginInfo.Email, Enabled = true, // The user is enabled by default IsExternal = true // IsExternal must always be true for users created via external authentication // Set any other required user properties using the data available in loginInfo }; // Attempts to create the user in the Xperience database IdentityResult result = await KenticoUserManager.CreateAsync(user); if (result.Succeeded) { // If the user was created successfully, creates a mapping between the user and the given authentication provider result = await KenticoUserManager.AddLoginAsync(user.Id, loginInfo.Login); } return(result); }