Do not try to authenticate when no credentials are set.
Set error_message in every case we return 0.
Mark these functions as static, as they are not used outside this file.
Fixed CS issues.