Fix exception handling in AuthenticateUser

Also catch SSLError separately for better troubleshooting