Refactored server-side socket authentication and modified chat validation