fix issue 1840, CAS failing due to redirect loop

there seems to be a minor bug with commit c87bf5, and therefore it solves the redirect loop preventing CAS authentication from working.
In my testing this patch fixes it. Note that this reverts to prior behaviour of checking the CAS provider to see if username is used to identify users. I'm not sure how this would work if the CAS provider was not web2py, I know nothing about CAS. But it was the old behaviour.