Move code for "closeLoginRegion" into a separate function (UserController).