We have arequirement where we want to be able to allow users to change their UserName. As episerver it does not allow username to be changed.
Does this mean we can never change UserName? We do need to change it though. Would really appreciate any input. Thanks!
You cannot change a username once it has been created, that is a restriction within ASP.NET. But you can create a new user in ASP.NET and link it to the Customer in Commerce.
// Create new user
var target= Membership.CreateUser(newUserName, newPassword, userEmailAddress);
if (RoleExists(AppRoles.EveryoneRole) &&!SecurityContext.Current.CheckUserInGlobalRole(target, AppRoles.EveryoneRole))
// Add user to registered role
if (RoleExists(AppRoles.RegisteredRole) && !SecurityContext.Current.CheckUserInGlobalRole(target, AppRoles.RegisteredRole))
// Get Customer
var customerContact = CustomerContext.Current.GetContactForUser(currentUser);
//assign new user to customer
customerContact.UserId = ToTypedString(target.ProviderUserKey);
// save customer
// delete 'old' account
Seems like it was discussed earlier here :http://world.episerver.com/Forum/Developer-forum/-EPiServer-75-CMS/Thread-Container/2014/7/Change-Username/
I haven't worked with Commerce before, I tested this with EPiServer CMS 7.5 only.
I guess you only want to change the username, and keep the old email.
Usernames are stored in the Users table. UserName is not PK / FK / unique constraint, so you can safely change it there.
User access rights are stored in tblContentAccess table. You need to change the Name column (free text).
Just make sure that 'new username' is not already in use.