Check for the onUserAuthenticate function before calling it. 

Also, a minor PHPCS fix.