I am having a double login issue with Moodle and CAS (v4.0.1). You can reproduce the error by logging out of moodle, and try to immediately login back. The first login does nothing, and you are prompted for a login page again. The scenario and resolution was also described in this blog post in
https://www.unicon.net/about/blogs/moodles-race-with-cas-server . I tried the solution but I am getting errors "Invalid property 'serviceManagerUrl' of bean class [org.jasig.cas.web.flow.TerminateWebSessionListener]: Bean property 'serviceManagerUrl' is not writable or has an invalid setter method." Maybe because the resolution was written for CAS 3.5.