Refactored panic for empty username in loginHandler to return JSON