Changed order of redirect and authentication.