Q:

DNN change username without logging out

I want to change the username of the currently logged-in user (programmatically) without logging the user out after doing that.
Here is the method code that I use
public void ChangeUsername(int userId, string newEmailAddress)
{
    UserController.ChangeUsername(userId, newEmailAddress);
}

Every time I change the username for any user, the user had to log in again after the update is done.
How to prevent this behavior?

A:

I got it
After many researches, I found that logging out the user is the default DNN behavior which makes sense to let the user login with his new email and also clear the DNN cache so you can see this user everywhere with his new email.
I can override the DNN behavior but this is not recommended and changing the email is something happening rarely so better to keep this behavior
Here is the DNN code

