Cannibalize code from Users.UsersController's login() method