I don't have time to look into this right now, but I'm a bit afraid that this is not taking into account the workflow that requires redirect_url = try_change_enrollment(request) (the above line), whose value you are overriding. 
I think the use case is that someone was redirected through the login workflow when they were not logged in but trying to enroll in a course.