Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Changing your user name produces an error and logs you out #2394
So I believe I've tracked this down to the BaseController, which is superseding the redirect_to call in _save_edit. The comment in there says the user needs to be forced to logout when they update their name (I'm not sure if this is correct) which is what is causing the issue.
I think this is redirecting back to the /user/edit/ page after performing the logout function which is what is generating the 401 error and then forcing the user to the login page since they're currently unauthenticated.
As for a fix, I'm not sure what the best way to approach this is, but I can probably dig around this week and see what I come up with.
Good spot finding the relevant code.
The authtkt cookie contains the user's name, so when you change your user.name in the database, then the cookie is out of date. Then when it gets to that code in BaseController you referenced, it finds that user name isn't in the database and therefore the best thing is to log you out. (The cookie's user name is read by the AuthKit middleware and that sets request.environ['REMOTE_USER'].)
The best solution would be to tell authtkt to change the cookie to have the new username.